Five friends (named Lion, Deer, Hare, Boar, and Tiger) have just come back from hunting with five dead animals of the same names. It is known that:
- Each has killed one animal, not corresponding to his/her own name, and:
- Each has missed another differently named animal, also not corresponding to his/her own name.
It is further known that:
1. The deer was killed by the hunter who has the name of the animal missed by Tiger.
2. The lion was killed by the hunter who has the name of the animal missed by Hare.
3. Deer, who missed a tiger, was very disappointed to kill only a hare.
Who killed and missed what animals?
DECLARE SUB permute (a$)
DIM names AS STRING, hit AS STRING, miss AS STRING
names = "ldhbt"
mrTiger = INSTR(names, "t")
mrHare = INSTR(names, "h")
mrDeer = INSTR(names, "d")
CLS
hit = "dhbtl": h$ = hit
DO
miss = "hbtld": m$ = miss
DO
good = 1
FOR i = 1 TO 5
IF MID$(names, i, 1) = MID$(hit, i, 1) THEN good = 0: EXIT FOR
IF MID$(names, i, 1) = MID$(miss, i, 1) THEN good = 0: EXIT FOR
IF MID$(miss, i, 1) = MID$(hit, i, 1) THEN good = 0: EXIT FOR
NEXT
IF good THEN
tgmiss$ = MID$(miss, mrTiger, 1)
drkiller = INSTR(names, tgmiss$)
IF MID$(hit, drkiller, 1) <> "d" THEN good = 0
hrmiss$ = MID$(miss, mrHare, 1)
hrkiller = INSTR(names, hrmiss$)
IF MID$(hit, hrkiller, 1) <> "l" THEN good = 0
IF MID$(miss, mrDeer, 1) <> "t" THEN good = 0
IF MID$(hit, mrDeer, 1) <> "h" THEN good = 0
IF good THEN
PRINT names: PRINT hit: PRINT miss
END IF
END IF
permute miss
LOOP UNTIL miss = m$
permute hit
LOOP UNTIL hit = h$
finds
ldhbt
dhtlb
htbdl
meaning
Mr. Lion killed the deer but missed the hare.
Mr. Deer killed the hare but missed the tiger.
Mr. Hare killed the tiger but missed the boar.
Mr. Boar killed the lion but missed the deer.
Mr. Tiger killed the boar but missed the lion.
|
Posted by Charlie
on 2014-02-13 01:30:14 |