RunRyder RC
WATCH
 2 pages [ <<    <    ( 1 )     2     NEXT    >> ] 1264 views Post Reply
Home🌌Off Topics🌌Off Topics Main Discussion › permutation calculator
06-17-2009 04:35 PM  11 years ago
Topic Vote0Post 1
Vance

rrVeteran

York ,PA

MyPosts All Forum Topic
permutation calculator
OK smart guys.
I need to find out how many different combinations can be had with 5 different items in a 50 lot.
I have 5 boxes that can fit into a shipper. The shipper can hold 50 boxes total. How many variations does that come out to be?
I tried looking for an online calculator but couldn't find one.
Thanks
Vince D
SHARE  PM  EMAIL  HOMEPAGE  GALLERY  Attn:RR  Quote
06-17-2009 04:42 PM  11 years ago
Vance

rrVeteran

York ,PA

MyPosts All Forum Topic
I "think" the answer is 2,118,760.
Can anyone confirm?
SHARE  PM  EMAIL  HOMEPAGE  GALLERY  Attn:RR  Quote
06-17-2009 04:46 PM  11 years ago
GyroFreak

rrProfessor

Orlando Florida ...28N 81W

MyPosts All Forum Topic
Need more info. How much does each box weigh, are they brown or white, is any box longer than the longest dimension of the container, are any fragile, what customs declaration is required, is this your homework ???I think about the hereafter. I go somewhere to get something, then wonder what I'm here after ?
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
06-17-2009 05:03 PM  11 years ago
Vance

rrVeteran

York ,PA

MyPosts All Forum Topic
No- I'm at work.
Think "The Sweetest Place On Earth"
I have 5 diff boxes of candy.
Hershey's:
Milk
Milk W/Almonds
KitKat
Reese peanut Butter Cup 24ct carton
Reese PBC 6ct carton.

The marketing dep't is asking me to fit these cartons into a shipper that will hold Roughly, 50 cartons.
I need to respond to them to let them know that there are literally millions of combinations of the above product that can fit into the unit. Roughly- 2 million combinations by my calculations.
SHARE  PM  EMAIL  HOMEPAGE  GALLERY  Attn:RR  Quote
06-17-2009 05:21 PM  11 years ago
nitro fun

rrApprentice

Oc ca

MyPosts All Forum Topic
Oops re read the top
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
06-17-2009 05:25 PM  11 years ago
JakeBrake

rrNovice

oHIo

MyPosts All Forum Topic
Just send all the Kit Kats to me. That will help. Yum YumPoliticians are like diapers, they both need changed often and for the same reason!
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
06-17-2009 05:43 PM  11 years ago
Vance

rrVeteran

York ,PA

MyPosts All Forum Topic
OK- Look at these & you can begin to understand how many different iterations are possible. I have to make their marketing dept. understand that they need to give me some direction as to what percentage distribution they would like for the product mix.

Milk-9
MWA-9
KK-9
Reeses PBC 24ct-7
Reese PBC 36ct-15

Milk-9
MWA-8
KK-9
Reeses PBC 24ct-8
Reese PBC 36ct-15

Milk-9
MWA-8
KK-9
Reeses PBC 24ct-9
Reese PBC 36ct-14

Milk-7
MWA-8
KK-9
Reeses PBC 24ct-10
Reese PBC 36ct-14

Oh- & I have literally hundreds of cases of Hershey candy in my office. I give it out to friends, family, postman,Etc. & my daughter's daycare. They love me at her daycare as I give them candy & then they're all jacked up on chocolate the rest of the day.
SHARE  PM  EMAIL  HOMEPAGE  GALLERY  Attn:RR  Quote
06-17-2009 05:48 PM  11 years ago
GyroFreak

rrProfessor

Orlando Florida ...28N 81W

MyPosts All Forum Topic
Man, what a sweet job. I would kill myself sampling all those products.
Sorry, don't have an answer for you, wish I did, I would request free samples for the answer.
I think about the hereafter. I go somewhere to get something, then wonder what I'm here after ?
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
06-17-2009 05:53 PM  11 years ago
GyroFreak

rrProfessor

Orlando Florida ...28N 81W

MyPosts All Forum Topic
Guesing here, but would it be 50 to fifth ?
Or:
(50X5)+(50X4)+(50X3)+(50X2)+50 ?

It's something like that.
I think about the hereafter. I go somewhere to get something, then wonder what I'm here after ?
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
06-17-2009 06:00 PM  11 years ago
Mark C

rrKey Veteran

Houston, TX - USA

MyPosts All Forum Topic
The answer 211876 was developed using a simple "lottery" type calculation. Or

49!/(45!5!) = 211876

This would not be the correct answer. Only the combinations where the total of the boxes = 50 are correct answers.

What you have to look at is combinations where the total of all boxes is equal to 50 so that limits the answer is only a mere 125,000 so get your a$$ to work packing

At least that is the answer I come up with.

EDIT: I was wrong
211876 is the correct answer and only includes combinations that add to 50. had an error in my equations

Damn! Hate it when that happens.

So you STILL really need to get you arse to packing!!!
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
06-17-2009 06:31 PM  11 years ago
homer

rrNovice

Gainesville - Florida

MyPosts All Forum Topic
No- I'm at work.
Think "The Sweetest Place On Earth"
I have 5 diff boxes of candy.
Hershey's:
Milk
Milk W/Almonds
KitKat
Reese peanut Butter Cup 24ct carton
Reese PBC 6ct carton.

The marketing dep't is asking me to fit these cartons into a shipper that will hold Roughly, 50 cartons.
I need to respond to them to let them know that there are literally millions of combinations of the above product that can fit into the unit. Roughly- 2 million combinations by my calculations.
Kool!!!! You work for the Mallo Cup factory in Altoona. Send me a box of them will you?
SHARE  PM  EMAIL  Attn:RR  Quote
06-17-2009 06:59 PM  11 years ago
Vance

rrVeteran

York ,PA

MyPosts All Forum Topic
Nope- I just finished off a 2 pack of Reese's peanut butter cups in dark chocolate after a lunch in the park behind my office which is directly across the street from Hershey Park. The chocolate smell wafts through my office in the warmer months when I open the front & back doors as one of the manufacturing plants is just down the street.
I can hear the people screaming from riding the roller coasters & I've been known to wander over there after lunch for a ride on a coaster. You definitely don't have to worry about falling asleep in the afternoon after a 60mph ride on one of those.
SHARE  PM  EMAIL  HOMEPAGE  GALLERY  Attn:RR  Quote
06-17-2009 07:42 PM  11 years ago
homer

rrNovice

Gainesville - Florida

MyPosts All Forum Topic
I knew you were near the Hershey plant by the way you wrote it. I just wanted to get your goat a little with the Mallo Cup remark. LOL

I always like working for Tropicana in Bradenton Fla. When they brought in the oranges and processed them it was a real pleasent smell.
SHARE  PM  EMAIL  Attn:RR  Quote
06-18-2009 02:51 AM  11 years ago
jphilli

rrKey Veteran

Atlanta, Ga.

MyPosts All Forum Topic
Actually, I believe 316251 is the correct answer.

Allow me to explain how:

The problem is essentially to count the number of integer solutions to x1+x2+x3+x4+x5=50. The variables correspond to the number of boxes of each particular type of candy; since there are 5 types of candy, there are 5 variables. The 50 comes from the fact that if you add together each quantity of candy then the total must always be 50 since the shipper holds 50 cartons.

Now what we'll do to find the answer is list out a string of 50 0's like so:

00000000000000000000000000000000000000000000000000

Now we will add 4 dividers 'randomly' in the string of 0's.

0I000000I00000000I000000000000000000000000000I00000000

Notice how after adding the 4 dividers we now have 5 groups of 0's. Each group of 0's represents the quantity of the boxes of each particular candy. In the previous example we have 1 x1, 6 x2, 8 x3, 27 x4 and 8 x5. Not surprisingly 1+6+8+27+8=50.

Now for another combination take a look at:
IIII00000000000000000000000000000000000000000000000000

Here we ran into a problem because in order for us to be able to count the number of combinations easily, the I's must not touch other I's. So to resolve this, we add to the string of 0's an additional 5 0's.

0000000000000000000000000000000000000000000000000000000

With 55 0's and 4 dividers, let's look at an example where we would only send out 4 types of candy.

0000000I0000000I0000000000000I0000000000000000000000I0

Here we see that x1=7, x2=7, x3=13, x4=22 and x5=1. But we must subtract 1 from each variable to get the true number of contents in the shipper.

Now the problem is very easy to count. With 55 0's and 54 spaces between those 0's, we need to distribute 4 I's. So 54 choose 4 = 54!/4!/50! = 316251.

Hope I explained it well enough guys. For what it's worth, I'm an applied math major at Ga. Tech so I have a little bit of experience with combinatorics.
SHARE  PM  EMAIL  Attn:RR  Quote
06-18-2009 03:59 AM  11 years ago
Vance

rrVeteran

York ,PA

MyPosts All Forum Topic
JPHilli- I'll take your word for it

If it were wintertime. I would send everyone who replied to this thread some Hershey's Chocolate. But it would melt in the heat of this season. I will give you this though. If any of you are up my way ever, I'll hook you up with the motherload of chocolate.
I took a big bag of it to the gym tonight & walked into a spin class in progress & handed the instructor a big bag of candy & said "spin this off". She's a friend so we all had a good laugh about it. The ladies love the chocolate & you'd be surprised what they will do for some
Vince D
SHARE  PM  EMAIL  HOMEPAGE  GALLERY  Attn:RR  Quote
06-18-2009 04:22 AM  11 years ago
jphilli

rrKey Veteran

Atlanta, Ga.

MyPosts All Forum Topic
HAHA, too funny Vance. You're like the Will Wonka of RunRyder.
SHARE  PM  EMAIL  Attn:RR  Quote
06-18-2009 04:33 AM  11 years ago
Mark C

rrKey Veteran

Houston, TX - USA

MyPosts All Forum Topic
I still think it is 211876.

I got that from a simple program to run all the possible combinations and count them up. That was after I did the straight calculation which I originally thought might not count for the sums having to add to 50 but as it turns out does.

And it so happens to also agree with Vance's original calculation.

I do assume that none of the items can never be 0. If indeed that is possible let me know and I'll rerun the numbers.

Quick and dirty stair-climbing routine to count the permutations:

int iBox1, iBox2, iBox3, iBox4, iBox5;
int iTotal = 0;

for (iBox1 = 1; iBox1 <= 46; iBox1++)
for (iBox2 = 1; iBox2 <= (50-1-1-iBox1); iBox2++)
for (iBox3 = 1; iBox3 <= (50-1-iBox1-iBox2); iBox3++)
for (iBox4 = 1; iBox4 <= (50-iBox1-iBox2-iBox3); iBox4++)
{
iBox5 = 50 - (iBox1 + iBox2 + iBox3 + iBox4);
if (iBox5 > 0)
iTotal++;
}

textBox1.Text = iTotal.ToString();

Mark C.
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
06-18-2009 04:54 AM  11 years ago
jphilli

rrKey Veteran

Atlanta, Ga.

MyPosts All Forum Topic
Mark, the difference is that you assumed that the minimum quantity per candy type is one and I took it as zero. Yes, your answer is correct for a min. of 1 as I checked that. However I didn't get the impression that there was a minimum number of various types of candy that must be present.

Out of curiosity, how long did it take your code to run through all the possibilities? I've done that sort of thing in the past but I've found that the combo. approach when dealing with large numbers to be signifigantly faster.
SHARE  PM  EMAIL  Attn:RR  Quote
06-18-2009 06:05 AM  11 years ago
Mark C

rrKey Veteran

Houston, TX - USA

MyPosts All Forum Topic
Mark, the difference is that you assumed that the minimum quantity per candy type is one and I took it as zero. Yes, your answer is correct for a min. of 1 as I checked that. However I didn't get the impression that there was a minimum number of various types of candy that must be present.
Yea... I figured that was a logical assumption. I figured he wanted at least 1 of any given candy.

If you do allow for 0 of any given candy then the algorithm simplifies to:

for (iBox1 = 0; iBox1 <= 50; iBox1++)
for (iBox2 = 0; iBox2 <= (50-iBox1); iBox2++)
for (iBox3 = 0; iBox3 <= (50-iBox1-iBox2); iBox3++)
for (iBox4 = 0; iBox4 <= (50-iBox1-iBox2-iBox3); iBox4++)
iTotal++;

And the answer is indeed 316251 .... same as yours
Out of curiosity, how long did it take your code to run through all the possibilities? I've done that sort of thing in the past but I've found that the combo. approach when dealing with large numbers to be signifigantly faster.
Na.... With a little trickery it's quite fast. Notice how the very inner loop only executes 316251 times? That is because the (50-iBox1-iBox2-iBox3) terms narrow down the loops to only execute for valid combinations.

On my machine, it executes in less than one millisecond. I tried capturing the System.Environment.TickCount to time it but the resolution of that timer is only in milliseconds and not even a tick goes by.
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
06-18-2009 06:55 AM  11 years ago
GimbalFan (RIP)

rrProfessor

Big Coppitt Key, FL

MyPosts All Forum Topic
I just polished off a pint o' Dreyers Ice Cream w/Reese's Peanut Butter Cups blended in.

Do dat 'count'?
op-thwop-thwop-thwop-thwop-thwop-thwop-thwop-thwop-thwop-thwop-thwop-thwop-t
SHARE  PM  EMAIL  GALLERY  Attn:RR  Quote
WATCH
 2 pages [ <<    <    ( 1 )     2     NEXT    >> ] 1264 views Post Reply
Home🌌Off Topics🌌Off Topics Main Discussion › permutation calculator
Print TOPIC

 5  Topic Subscribe

Saturday, January 16 - 5:32 pm - Copyright © 2000-2021 RunRyder   EMAILEnable Cookies

Login Here
 New Subscriptions 
 Buddies Online