In a game of poker, one of the hands of five cards had the following features:
- There was no card above a 10 (an ace is above a 10 in poker).
- No two cards were of the same value.
- All four suits were represented.
- The total values of the odd and even cards were equal.
- No three cards were in sequence.
- The black cards totaled 10 in value.
- The hearts totaled 14.
- The lowest card was a spade.
What was the hand?
DECLARE SUB permute (a$)
CLS
FOR a = 2 TO 6
v(1) = a
IF a MOD 2 = 1 THEN oddtot = oddtot + a: ELSE eventot = eventot + a
FOR b = a + 1 TO 7
v(2) = b
IF b MOD 2 = 1 THEN oddtot = oddtot + b: ELSE eventot = eventot + b
FOR c = b + 1 TO 8
v(3) = c
IF c MOD 2 = 1 THEN oddtot = oddtot + c: ELSE eventot = eventot + c
FOR d = c + 1 TO 9
v(4) = d
IF d MOD 2 = 1 THEN oddtot = oddtot + d: ELSE eventot = eventot + d
FOR e = d + 1 TO 10
v(5) = e
IF e MOD 2 = 1 THEN oddtot = oddtot + e: ELSE eventot = eventot + e
IF c - a = 2 OR d - b = 2 OR e - c = 2 THEN good = 0: ELSE good = 1
IF good THEN
IF oddtot = eventot THEN
PRINT : PRINT a; b; c; d; e
a$ = "shdc": h$ = a$
GOSUB chkperms
a$ = "hhdc": h$ = a$
GOSUB chkperms
a$ = "hddc": h$ = a$
GOSUB chkperms
a$ = "hdcc": h$ = a$
GOSUB chkperms
END IF
END IF
IF e MOD 2 = 1 THEN oddtot = oddtot - e: ELSE eventot = eventot - e
NEXT
IF d MOD 2 = 1 THEN oddtot = oddtot - d: ELSE eventot = eventot - d
NEXT
IF c MOD 2 = 1 THEN oddtot = oddtot - c: ELSE eventot = eventot - c
NEXT
IF b MOD 2 = 1 THEN oddtot = oddtot - b: ELSE eventot = eventot - b
NEXT
IF a MOD 2 = 1 THEN oddtot = oddtot - a: ELSE eventot = eventot - a
NEXT
END
chkperms:
DO
suit$ = "s" + a$
btot = 0: htot = 0
FOR i = 1 TO 5
IF MID$(suit$, i, 1) = "s" OR MID$(suit$, i, 1) = "c" THEN btot = btot + v(i)
IF MID$(suit$, i, 1) = "h" THEN htot = htot + v(i)
NEXT
IF btot = 10 AND htot = 14 THEN
PRINT suit$
END IF
permute a$
LOOP UNTIL a$ = h$
RETURN
finds
2 4 5 8 9
sdhch
2 4 7 9 10
indicating the denominations were 2,4,5,8 and 9 and their respective suits were s, d, h, c and h.
The additional set of denominations fit the denomination tests but could not be fit to the suit tests.
BTW, if clue 5 were left out, the solution would still be the same, but the half-solutions (only the denomination tests done) would have been greater in number:
2 3 4 6 9
2 4 5 6 7
2 4 5 8 9
sdhch
2 4 7 9 10
2 6 7 8 9
Edited on April 19, 2013, 1:09 pm
|
Posted by Charlie
on 2013-04-19 13:06:57 |