in reply to unordered sets of N elements
Extending to three dice, we have the following - set to 1-1 and we have 6 possibilities. 1-2 and we have 5, etc. So, with the first die as 1, we have the above 21 possibilities. Setting the first die to 2 and we have 5 possibilities for the second and 4 for the third - leaving us 15 total possibilities. So, the total ends up being 21 + 15 + 10 + 6 + 3 + 1 = 56, which is borne out by your code.
You can extend the pattern upwards. The actual formula involves a bunch of Sigmas.
d = 6, n = 2 ==> S(i=1->d)(i) d = 6, n = 3 ==> S(i=1->d)(S(j=1->i)(j) The inductive rule is: F(2) ==> S(i=1->d)(i) F(n) ==> S(i=1->d)(F(n-1))
I'm sure there's a straight formula, but my brain hurts. :-)
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: unordered sets of N elements
by japhy (Canon) on Jul 13, 2004 at 13:47 UTC | |
by dragonchild (Archbishop) on Jul 13, 2004 at 13:50 UTC | |
by Limbic~Region (Chancellor) on Jul 13, 2004 at 14:39 UTC |