There are five bags of coins such that:
a) the weight of any coin (in ounces) is a positive integer less than or equal to w
b) all coins in a given bag weigh the same
c) the weight of a coin in bag #1 is different from the weight of a coin in bag #2
d) when one coin from bag #1, w coins from bag #2, w^{2} coins from bag #3, w^{3} coins from bag #4, and w^{4} coins from bag #5 are combined and weighed, the result is 2800 ounces
Determine analytically, the weight of a coin in each of the five bags.
The weight of each coin can be considered a digit in a variant of basew representation. In the usual basew representation, digits can be from 0 to w1, but in this variation, they go from 1 to w.
The usual base conversion method is to divide the number by the base. The remainder becomes the first (or next) digit, placed to the left of any preciding digits found, and then using the quotient as the new dividend for the process to continue.
In this case, we must convert any zero remainders to w. At the same time, we must subtract 1 from the quotient before using it as the next dividend, to account for the "borrowing" done.
As the powers of the base go from zero to four, we need a 5digit number in the peculiar basew system to represent 2800 decimal. So we can try various bases. The following table shows this basew representation for various w:
2 12122221112
3 3211131
4 223234
5 42145
6 16544
7 7777
8 5358
9 3751
10 279a
11 2116
12 1754
13 1375
14 e3e
15 c6a
16 aeg
17 9bc
18 8ba
19 7e7
20 6jk
Note that a=10, b=11, c=12, etc. in decimal representation.
So for the base w being 5 or 6, we get a 5digit representation of 2800 decimal.
As the lower powers of w are on the right in interpreting the numbers, bag 1 is represented by the rightmost digit and bag 5 by the leftmost.
When the base is 6, the rightmost two digits are the same, and thus bags 1 and 2 would have the same weight coins so this possibility is disqualified.
So the weights of the coins in bags 1 through 5 are 5, 4, 1, 2 and 4 respectively.
The following program tries the bases, b, from 2 to 20, resulting in the above table:
CLS
n = 2800
FOR b = 2 TO 20
m = n
ns$ = ""
DO
d = m MOD b
m = m \ b
IF d = 0 THEN d = b: m = m  1
ns$ = MID$("0123456789abcdefghijklmnopqrstuvwxyz", d + 1, 1) + ns$
LOOP UNTIL m = 0
PRINT b, ns$
NEXT b

Posted by Charlie
on 20070221 17:01:05 