BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
Update2: 13824 is 29 * 33; but how you get that from 3 & 4 or 12 & 3 or 12 & 4???
If you have N identical sets of M different things, how many different orderings can they be arranged in? (Ie. What's the formula?)
Eg. if you have 2 sets of 3: my %stats; ++$stats{ join'', shuffle( ( 1..3 ) x 2 ) } for 1 .. 1e6
For the above example, with M=3 and varying N, I gets the following numbers:
And for M=4:
And for M=5:
Oh. And for the "What have you tried" crowd: I've been thinking about it for days; I've stared at the various algorithms in Algorithm::Combinatorics trying to work out which is applicable; and a few unsuccessful google searches looking for a relevant problem description.
As you can see, the numbers compound very quickly; and I need to calculate for considerably higher numbers; but I cannot wrap my brain around it.
For the very simplest (first) case above I get these results:
C:\test>junk39 -M=3 -N=2 -I=1e4 90 { 112233 => 117, 112323 => 119, 112332 => 120, 113223 => 112, 113232 => 104, 113322 => 115, 121233 => 121, 121323 => 118, 121332 => 97, 122133 => 114, 122313 => 97, 122331 => 112, 123123 => 122, 123132 => 118, 123213 => 118, 123231 => 121, 123312 => 95, 123321 => 105, 131223 => 101, 131232 => 116, 131322 => 112, 132123 => 110, 132132 => 120, 132213 => 114, 132231 => 134, 132312 => 101, 132321 => 103, 133122 => 122, 133212 => 105, 133221 => 113, 211233 => 113, 211323 => 114, 211332 => 86, 212133 => 135, 212313 => 107, 212331 => 113, 213123 => 117, 213132 => 115, 213213 => 131, 213231 => 113, 213312 => 120, 213321 => 114, 221133 => 120, 221313 => 119, 221331 => 103, 223113 => 107, 223131 => 100, 223311 => 109, 231123 => 115, 231132 => 119, 231213 => 119, 231231 => 106, 231312 => 122, 231321 => 107, 232113 => 117, 232131 => 93, 232311 => 108, 233112 => 103, 233121 => 110, 233211 => 92, 311223 => 107, 311232 => 132, 311322 => 94, 312123 => 102, 312132 => 105, 312213 => 95, 312231 => 121, 312312 => 98, 312321 => 111, 313122 => 94, 313212 => 122, 313221 => 114, 321123 => 110, 321132 => 105, 321213 => 127, 321231 => 113, 321312 => 117, 321321 => 107, 322113 => 122, 322131 => 91, 322311 => 108, 323112 => 126, 323121 => 97, 323211 => 98, 331122 => 111, 331212 => 120, 331221 => 91, 332112 => 116, 332121 => 123, 332211 => 100, }
If you count the number of 1s,2s,& 3s in the 6 columns they are all equal at 30; hence 90 possible comb/permutations. But if there was a free choice of digit for all positions; it would be 36==729 combinations.
And if you could treat each group separately as permutations, and combined them it would be 3! * 3! = 36.
At this point, I've run out of ideas, so ... this post.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Combinatorics formula
by tybalt89 (Monsignor) on Oct 19, 2016 at 00:03 UTC | |
by Anonymous Monk on Oct 19, 2016 at 00:16 UTC | |
by BrowserUk (Patriarch) on Oct 19, 2016 at 00:11 UTC | |
|
Re: Combinatorics formula
by pryrt (Abbot) on Oct 19, 2016 at 00:06 UTC | |
by BrowserUk (Patriarch) on Oct 19, 2016 at 00:11 UTC |