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 J, K, L and M of Realmazure were busy in a conversation, when another visitor from a neighboring planet stopped by and asked each of them their identity. They said:
Inhabitant J
1. M is a Pretender.
2. K’s first statement is true.
3. M’s third statement is true.
Inhabitant K
1. J is a not a Knight.
2. J’s first statement is true.
3. M is a Prevaricator.
Inhabitant L
1. J is a Prevaricator.
2. M is a Liar.
3. K’s second statement is false.
Inhabitant M
1. L’s third statement is true.
2. I am a Pretender.
3. J is a Knight.
Determine the type of each of the four inhabitants in terms of the above statements.
(In reply to
solution by Daniel)
But K1 and K2 are both true, so K is a Prevaricator rather than a Pretender.
Truth values and speaker types:
J K L M
1 1 0 1 1 0 1 0 0 0 1 0
2 2 1 1
where 1 is true and 0 false on the first line and 2 indicates prevaricator and 1 is pretender on the second line.
DECLARE SUB choose (s!)
DIM SHARED stmt(12), typ(4)
choose 1
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(4) = 1) THEN good = 0: EXIT FOR
IF stmt(2) <> (stmt(4) = -1) THEN good = 0: EXIT FOR
IF stmt(3) <> (stmt(12) = -1) THEN good = 0: EXIT FOR
IF stmt(4) <> (typ(1) <> 3) THEN good = 0: EXIT FOR
IF stmt(5) <> (stmt(1) = -1) THEN good = 0: EXIT FOR
IF stmt(6) <> (typ(4) = 2) THEN good = 0: EXIT FOR
IF stmt(7) <> (typ(1) = 2) THEN good = 0: EXIT FOR
IF stmt(8) <> (typ(4) = 0) THEN good = 0: EXIT FOR
IF stmt(9) <> (stmt(5) = 0) THEN good = 0: EXIT FOR
IF stmt(10) <> (stmt(9) = -1) THEN good = 0: EXIT FOR
IF stmt(11) <> (typ(4) = 1) THEN good = 0: EXIT FOR
IF stmt(12) <> (typ(1) = 3) 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-09-23 12:53:47 |