3 jealous brothers are to divvy up a set of commemorative coins.
There are an equal number of coins of each of the values: $1, $2, $3.
They discover that it is possible to do this in such a way that each brother gets a different assortment of coins, yet each gets the same number of coins and the same total value of coins.
What's the smallest possible number of coins in the set?
CLS
FOR n = 1 TO 100
value = 6 * n
coins = 3 * n
valeach = 2 * n
coinseach = n
FOR a1 = 0 TO n
FOR a2 = 0 TO n - a1
a3 = n - a1 - a2
vala = a1 + 2 * a2 + 3 * a3
IF vala = valeach THEN
FOR b1 = 0 TO n - a1
FOR b2 = 0 TO n - a2
IF b1 + b2 <= coinseach THEN
b3 = n - b1 - b2
IF a3 + b3 <= n THEN
valb = b1 + 2 * b2 + 3 * b3
IF valb = valeach THEN
c1 = n - a1 - b1
c2 = n - a2 - b2
c3 = n - a3 - b3
a$ = STR$(a1) + STR$(a2) + STR$(a3)
b$ = STR$(b1) + STR$(b2) + STR$(b3)
c$ = STR$(c1) + STR$(c2) + STR$(c3)
IF a$ < b$ AND b$ < c$ THEN
PRINT n; 3 * n, a1; a2; a3, b1; b2; b3, c1; c2; c3
ct = ct + 1
END IF
END IF
END IF
END IF
NEXT
NEXT
END IF
NEXT a2
NEXT a1
IF ct > 44 THEN END
NEXT n
finds the smallest number of coins is 6 per denomination, or 18 altogether, as shown as the first way on the following table:
no. of coins numbers of coins by brother
------------ -----------------------------------
per
den total $1 $2 $3 $1 $2 $3 $1 $2 $3
6 18 1 4 1 2 2 2 3 0 3
8 24 1 6 1 3 2 3 4 0 4
9 27 2 5 2 3 3 3 4 1 4
10 30 1 8 1 4 2 4 5 0 5
10 30 2 6 2 3 4 3 5 0 5
11 33 2 7 2 4 3 4 5 1 5
12 36 1 10 1 5 2 5 6 0 6
12 36 2 8 2 4 4 4 6 0 6
12 36 3 6 3 4 4 4 5 2 5
13 39 2 9 2 5 3 5 6 1 6
13 39 3 7 3 4 5 4 6 1 6
14 42 1 12 1 6 2 6 7 0 7
14 42 2 10 2 5 4 5 7 0 7
14 42 3 8 3 4 6 4 7 0 7
14 42 3 8 3 5 4 5 6 2 6
15 45 2 11 2 6 3 6 7 1 7
15 45 3 9 3 5 5 5 7 1 7
15 45 4 7 4 5 5 5 6 3 6
16 48 1 14 1 7 2 7 8 0 8
16 48 2 12 2 6 4 6 8 0 8
16 48 3 10 3 5 6 5 8 0 8
16 48 3 10 3 6 4 6 7 2 7
16 48 4 8 4 5 6 5 7 2 7
17 51 2 13 2 7 3 7 8 1 8
17 51 3 11 3 6 5 6 8 1 8
17 51 4 9 4 5 7 5 8 1 8
17 51 4 9 4 6 5 6 7 3 7
18 54 1 16 1 8 2 8 9 0 9
18 54 2 14 2 7 4 7 9 0 9
18 54 3 12 3 6 6 6 9 0 9
18 54 3 12 3 7 4 7 8 2 8
18 54 4 10 4 5 8 5 9 0 9
18 54 4 10 4 6 6 6 8 2 8
18 54 5 8 5 6 6 6 7 4 7
19 57 2 15 2 8 3 8 9 1 9
19 57 3 13 3 7 5 7 9 1 9
19 57 4 11 4 6 7 6 9 1 9
19 57 4 11 4 7 5 7 8 3 8
19 57 5 9 5 6 7 6 8 3 8
20 60 1 18 1 10 0 10 9 2 9
20 60 3 14 3 8 4 8 9 2 9
20 60 4 12 4 7 6 7 9 2 9
20 60 5 10 5 6 8 6 9 2 9
20 60 5 10 5 7 6 7 8 4 8
20 60 10 0 10 2 16 2 8 4 8
20 60 10 0 10 3 14 3 7 6 7
20 60 10 0 10 4 12 4 6 8 6
|
Posted by Charlie
on 2013-02-06 17:01:18 |