A distant planet is inhabited by creatures having more than two arms. The ones with an even number of arms are the knights who always tell the truth; the ones with an odd number of arms are the liars who always speak falsely.
The rules of the planet allow only creatures having eight, nine or ten arms to work as guards. Four guards are conversing amongst themselves:
- The magenta one says, "All together we have 39 arms."
- The cyan one says, "No, we do not."
- The brown one says, "The beige one has 8 arms."
- The beige one says, "The brown one is lying."
Determine the number of arms of each guard.
FOR magenta = 8 TO 10
FOR cyan = 8 TO 10
FOR brown = 8 TO 10
FOR beige = 8 TO 10
good = 1
tot = magenta + cyan + brown + beige
IF (magenta <> 9) <> (tot = 39) THEN good = 0
IF (cyan <> 9) <> (tot <> 39) THEN good = 0
IF (brown <> 9) <> (beige = 8) THEN good = 0
IF (beige <> 9) <> (brown = 9) THEN good = 0
IF good THEN
PRINT magenta; cyan; brown; beige
9 8 9 10
9 10 9 10
as alternate solutions for the number of arms of magenta, cyan, brown and beige respectively.
Either way, cyan is telling the truth that magenta is lying, as in one case they have 36 arms all together and in the other case 38.
Posted by Charlie
on 2012-12-03 17:58:07