The inhabitants of the planet Realmazure are Knights, Pretenders, Prevaricators or Liars.
All the statements by a Knight are true, a Pretender will tell precisely one true statement, a Prevaricator will tell precisely two true statements, and all the statements made by a Liar will be false.
Four inhabitants E, F, G and H of Realmazure were busy in a conversation, when a visitor from a neighboring planet stopped by and asked each of them their identity. They said:
Inhabitant E
- I am a Pretender
- G’s second statement is false.
- F is not a Prevaricator.
Inhabitant F
- H is a Liar.
- G’s second statement is true.
- E’s second statement is true.
Inhabitant G
- F’s second statement is true.
- E’s first statement is false.
- F is a Prevaricator.
Inhabitant H
- I am a Knight.
- E is a Pretender.
- F’s third statement is true.
Determine the type of each of the four inhabitants in terms of the above statements.
The statements (1 = true, 0 = false):
---E--- ---F--- ---G--- ---H---
0 0 0 1 1 0 1 1 1 0 0 0
making the types:
E F G H
0 2 3 0
where 0 = liar, 1 = pretender, 2 = prevaricator, 3 = knight
DECLARE SUB choose (s!)
DIM SHARED stmt(12), typ(4)
choose 1
END
SUB choose (s)
FOR tr = -1 TO 0 ' -1 is true
stmt(s) = tr
SELECT CASE s
CASE 3
typ(1) = 0
FOR i = 1 TO 3
typ(1) = typ(1) + ABS(stmt(i))
NEXT
choose s + 1
CASE 6
typ(2) = 0
FOR i = 4 TO 6
typ(2) = typ(2) + ABS(stmt(i))
NEXT
choose s + 1
CASE 9
typ(3) = 0
FOR i = 7 TO 9
typ(3) = typ(3) + ABS(stmt(i))
NEXT
choose s + 1
CASE 12
typ(4) = 0
FOR i = 10 TO 12
typ(4) = typ(4) + ABS(stmt(i))
NEXT
good = 1
FOR j = 1 TO 1
IF stmt(1) <> (typ(1) = 1) THEN good = 0: EXIT FOR
IF stmt(2) <> (stmt(8) = 0) THEN good = 0: EXIT FOR
IF stmt(3) <> (typ(2) <> 2) THEN good = 0: EXIT FOR
IF stmt(4) <> (typ(4) = 0) THEN good = 0: EXIT FOR
IF stmt(5) <> (stmt(8) = -1) THEN good = 0: EXIT FOR
IF stmt(6) <> (stmt(2) = -1) THEN good = 0: EXIT FOR
IF stmt(7) <> (stmt(5) = -1) THEN good = 0: EXIT FOR
IF stmt(8) <> (stmt(1) = 0) THEN good = 0: EXIT FOR
IF stmt(9) <> (typ(2) = 2) THEN good = 0: EXIT FOR
IF stmt(10) <> (typ(4) = 3) THEN good = 0: EXIT FOR
IF stmt(11) <> (typ(1) = 1) THEN good = 0: EXIT FOR
IF stmt(12) <> (stmt(6) = -1) THEN good = 0: EXIT FOR
NEXT
IF good THEN
FOR j = 1 TO 12
PRINT -stmt(j);
IF j MOD 3 = 0 THEN PRINT " ";
NEXT: PRINT
FOR j = 1 TO 4: PRINT typ(j); : NEXT: PRINT
PRINT
END IF
CASE ELSE
choose s + 1
END SELECT
NEXT
END SUB
|
Posted by Charlie
on 2009-08-02 15:07:28 |