This is in continuation of
Pumpkins and
Pumpkins 2.
Six pumpkins - each having a different weight - are weighed two at a time in all 15 sets of two. The weights are recorded as: 27, 36, 39, 45, 48, 51, 54, 57, 63, 66, 72, 75 and 81 pounds.
- Precisely two of the values occurred exactly twice, but these values were only written down once.
- Each of the individual weights (in pounds) is a positive integer.
Derive the weights of the pumpkins and which two values occur twice.
DECLARE SUB test (x!, y!)
DIM SHARED good, sumct(81)
CLS
FOR a = 1 TO 14
b = 27 - a
c = 36 - a
FOR f = c + 1 TO 81
e = 81 - f
d = 75 - f
IF d > c AND e > d THEN
FOR i = 1 TO 81: sumct(i) = 0: NEXT
sumct(27) = 1: sumct(36) = 1: sumct(81) = 1: sumct(75) = 1
good = 1
test a, d
test a, e
test a, f
test b, c
test b, d
test b, e
test b, f
test c, d
test c, e
test c, f
test d, e
IF good THEN
PRINT a; b; c; d; e; f
FOR i = 1 TO 81
SELECT CASE i
CASE 27, 36, 39, 45, 48, 51, 54, 57, 63, 66, 72, 75, 81
PRINT i; sumct(i),
END SELECT
NEXT
PRINT : PRINT
END IF
END IF
NEXT f
NEXT a
SUB test (x, y)
sum = x + y
SELECT CASE sum
CASE 27, 36, 39, 45, 48, 51, 54, 57, 63, 66, 72, 75, 81
found = 1
sumct(sum) = sumct(sum) + 1
CASE ELSE
found = 0
END SELECT
IF found = 0 THEN good = 0
END SUB
reports
9 18 27 30 36 45
27 1 36 1 39 1 45 2 48 1
51 0 54 2 57 1 63 2 66 1
72 1 75 1 81 1
12 15 24 33 39 42
27 1 36 1 39 1 45 1 48 1
51 1 54 2 57 2 63 1 66 1
72 1 75 1 81 1
The first set has no 51 as a sum, while 45, 54 and 63 are all repeated.
The second set fulfills the conditions:
12, 15, 24, 33, 39 and 42 pounds.
The repeated totals are 54 and 57.
|
Posted by Charlie
on 2014-01-22 11:38:11 |