All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 5 partitions (Posted on 2012-11-21)
Grandma Jones bought 15 identical chocolate bars for her six grandchildren (named A,B,C,D,E and F).

How many possible ways to divide those bars are there for each of the following exclusive cases:

a) Each of the grandchildren gets a distinct number of bars
b) Only two of the grandchildren get the same number of bars
c) Each of the grandchildren gets at least 1 chocolate bar
d) No restrictions
e) A gets more than B, no other restrictions

Comments: ( Back to comment list | You must be logged in to post comments.)
 solutions | Comment 2 of 3 |

First (d):

With 15 bars and 5 partitions between what's given to each of the six children, the answer to (d) is C(20,5)=15504.

Then (c):

After giving one bar to each child, it's a question of dividing 9 bars among the six kids (9 bars and 5 partitions): C(14,5)=2002.

For the rest:

FOR a = 0 TO 15
FOR b = 0 TO 15 - a
FOR c = 0 TO 15 - a - b
FOR d = 0 TO 15 - a - b - c
FOR e = 0 TO 15 - a - b - c - d
f = 15 - a - b - c - d - e
IF a <> b AND a <> c AND a <> d AND a <> e AND a <> f THEN
IF b <> c AND b <> d AND b <> e AND b <> f THEN
IF c <> d AND c <> e AND c <> f THEN
IF d <> e AND d <> f THEN
IF e <> f THEN
parta = parta + 1
END IF
END IF
END IF
END IF
END IF

totb = (a <> b) + (a <> c) + (a <> d) + (a <> e) + (a <> f)
totb = totb + (b <> c) + (b <> d) + (b <> e) + (b <> f)
totb = totb + (c <> d) + (c <> e) + (c <> f)
totb = totb + (d <> e) + (d <> f) + (e <> f)
totb = ABS(totb)
IF totb = 14 THEN partb = partb + 1

IF a > b THEN parte = parte + 1
NEXT
NEXT
NEXT
NEXT
NEXT
PRINT "a"; parta
PRINT "b"; partb
PRINT "e"; parte

finds

part count
a    720
b    4680
e    6672

 Posted by Charlie on 2012-11-21 17:24:02

 Search: Search body:
Forums (0)