From: Dan Joseph on 22 Apr 2010 10:07 Howdy, This is a math question, but I'm doing the code in PHP, and have expunged all resources... hoping someone can guide me here. For some reason, I can't figure this out. I want to take a group of items, and divide them into equal groups based on a max per group. Example. 1,252,398 -- divide into equal groups with only 30 items per group max. Can anyone guide me towards an algorithm or formula name to solve this? PHP code or Math stuff is fine. Either way... Thanks... -- -Dan Joseph www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo Code "NEWTHINGS" for 10% off initial order http://www.facebook.com/canishosting http://www.facebook.com/originalpoetry
From: Stephen on 22 Apr 2010 10:12 Dan Joseph wrote: > I want to take a group of items, and divide them into equal groups based on > a max per group. Example. > > 1,252,398 -- divide into equal groups with only 30 items per group max. > > > 1,252,398 DIV 30 = 41,746 groups of 30. 1,252,398 MOD 30 = 18 items in last group Stephen
From: Dan Joseph on 22 Apr 2010 10:17 On Thu, Apr 22, 2010 at 10:12 AM, Stephen <stephen-d(a)rogers.com> wrote: > 1,252,398 DIV 30 = 41,746 groups of 30. > > 1,252,398 MOD 30 = 18 items in last group > Well, the only problem with going that route, is the one group is not equally sized to the others. 18 is ok for a group in this instance, but if it was a remainder of only 1 or 2, there would be an issue. Which is where I come to looking for a the right method to break it equally. -- -Dan Joseph www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo Code "NEWTHINGS" for 10% off initial order http://www.facebook.com/canishosting http://www.facebook.com/originalpoetry
From: Ashley Sheridan on 22 Apr 2010 10:13 On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote: > On Thu, Apr 22, 2010 at 10:12 AM, Stephen <stephen-d(a)rogers.com> wrote: > > > 1,252,398 DIV 30 = 41,746 groups of 30. > > > > 1,252,398 MOD 30 = 18 items in last group > > > Well, the only problem with going that route, is the one group is not > equally sized to the others. 18 is ok for a group in this instance, but if > it was a remainder of only 1 or 2, there would be an issue. Which is where > I come to looking for a the right method to break it equally. > How do you mean break it equally? If the number doesn't fit, then you've got a remainder, and no math is going to change that. How do you want that remainder distributed? Thanks, Ash http://www.ashleysheridan.co.uk
From: "Jo�o C�ndido de Souza Neto" on 22 Apr 2010 10:24 for ($g = $maxpergroup; $g > 0; $g++) { if ($items mod $g <> 0) continue; $Groups = $items div $g; } Maybe it can helps you. "Dan Joseph" <dmjoseph(a)gmail.com> escreveu na mensagem news:q2oa20394491004220707x980cef5ej2b310c97d123056b(a)mail.gmail.com... > Howdy, > > This is a math question, but I'm doing the code in PHP, and have expunged > all resources... hoping someone can guide me here. For some reason, I > can't > figure this out. > > I want to take a group of items, and divide them into equal groups based > on > a max per group. Example. > > 1,252,398 -- divide into equal groups with only 30 items per group max. > > Can anyone guide me towards an algorithm or formula name to solve this? > PHP > code or Math stuff is fine. Either way... > > Thanks... > > -- > -Dan Joseph > > www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo > Code "NEWTHINGS" for 10% off initial order > > http://www.facebook.com/canishosting > http://www.facebook.com/originalpoetry >
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Updating cli executable on MS-Windows Next: Replace a space with a newline every 2 spaces |