Five pumpkins are weighed two at a time in all possible combinations, similar to the
first pumpkins puzzle. The results of the weighings gives nine different values: 52, 56, 60, 68, 72, 76, 80, 84, and 88. One of the values was repeated, but which value was not written down.
Find out the weights of the pumpkins and which value is the repeat.
DATA 52, 56, 60, 68, 72, 76, 80, 84, 88
CLS
FOR i = 1 TO 9
READ w(i)
t = t + w(i)
NEXT
max = (t + w(9)) / 20
min = (t + w(1)) / 20
PRINT min, max
FOR w1 = 0 TO 26
lg = 80 - w1 ' arbitrary guess
w2 = 52 - w1
FOR w3 = w2 + 2 TO lg STEP 2
FOR w4 = w3 + 2 TO lg STEP 2
FOR w5 = w4 + 2 TO lg STEP 2
IF w4 + w5 = 88 THEN
REDIM ttl(111)
REDIM ttl2(111)
ttl(w1 + w3) = 1
ttl(w1 + w4) = 1
ttl(w1 + w5) = 1
ttl(w2 + w3) = 1
ttl(w2 + w4) = 1
ttl(w2 + w5) = 1
ttl(w3 + w4) = 1
ttl(w3 + w5) = 1
ttl2(w1 + w3) = ttl2(w1 + w3) + 1
ttl2(w1 + w4) = ttl2(w1 + w4) + 1
ttl2(w1 + w5) = ttl2(w1 + w5) + 1
ttl2(w2 + w3) = ttl2(w2 + w3) + 1
ttl2(w2 + w4) = ttl2(w2 + w4) + 1
ttl2(w2 + w5) = ttl2(w2 + w5) + 1
ttl2(w3 + w4) = ttl2(w3 + w4) + 1
ttl2(w3 + w5) = ttl2(w3 + w5) + 1
IF ttl(56) AND ttl(60) AND ttl(68) AND ttl(72) AND ttl(76) AND ttl(80) AND ttl(84) THEN
PRINT w1; w2; w3; w4; w5
FOR i = 1 TO 111
IF ttl2(i) = 2 THEN PRINT i
NEXT
END IF
END IF
NEXT
NEXT
NEXT
NEXT
produces
34.4 36.2
20 32 36 40 48
68
the first two numbers being merely the lowest possible average and highest possible average for the pumpkins' weights, used in initial thinking about the problem.
|
Posted by Charlie
on 2005-09-08 20:08:23 |