All six sets of three possible scores of 71 in six shots are actually the same--just the six permutations of the three sets:
50 10 5 3 2 1
25 20 20 3 2 1
25 20 10 10 5 1
50 10 5 3 2 1
25 20 10 10 5 1
25 20 20 3 2 1
25 20 20 3 2 1
50 10 5 3 2 1
25 20 10 10 5 1
25 20 20 3 2 1
25 20 10 10 5 1
50 10 5 3 2 1
25 20 10 10 5 1
50 10 5 3 2 1
25 20 20 3 2 1
25 20 10 10 5 1
25 20 20 3 2 1
50 10 5 3 2 1
Only the 25 20 20 3 2 1 is capable of having 22 in two shots, and the only remaining one with a 3 is 50 10 5 3 2 1, who must be Ricardo, who thus has the 50.
DECLARE SUB addOn (wh!)
DATA 50,1
DATA 25,2
DATA 20,3
DATA 10,3
DATA 5,2
DATA 3,2
DATA 2,2
DATA 1 ,3
DIM SHARED denom(8, 2)
DIM SHARED used(8), h(18), tot, ct
FOR d = 1 TO 8
READ denom(d, 1), denom(d, 2)
NEXT
CLS
addOn 1
PRINT ct
SUB addOn (wh)
IF wh = 1 OR wh = 7 THEN st = 1: ELSE st = h(wh - 1)
IF wh <= 6 THEN goal = 71: ELSE goal = 142
FOR i = st TO 8
IF used(i) < denom(i, 2) THEN
IF denom(i, 1) < goal - tot AND wh <> 6 AND wh <> 12 OR denom(i, 1) = goal - tot AND (wh = 6 OR wh = 12) THEN
h(wh) = i
used(i) = used(i) + 1
tot = tot + denom(i, 1)
IF wh = 12 THEN
FOR j = 1 TO 6: PRINT denom(h(j), 1); : NEXT: PRINT
FOR j = 7 TO 12: PRINT denom(h(j), 1); : NEXT: PRINT
FOR j = 1 TO 8
FOR k = 1 TO denom(j, 2) - used(j)
PRINT denom(j, 1);
NEXT
NEXT
PRINT : PRINT
ct = ct + 1
ELSE
addOn wh + 1
END IF
tot = tot - denom(i, 1)
used(i) = used(i) - 1
END IF
END IF
NEXT
END SUB
|
Posted by Charlie
on 2014-02-25 15:56:42 |