All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 De Ja True? (Posted on 2007-09-29)
Alex, Bert, and Carl are each a knight, knave or a liar. Three people asked them what their types were.

The first person got the following responses:
Alex:Carl is a liar.
Bert:Alex is a knight.
Carl:Bert is a knave.

The second person got the following responses but forgot who made which ones:
Exactly one of us is a knight.
Exactly one of us is a knave.
Exactly one of us is a liar.
(Alex, Bert, and Carl each made one of the statements.)

The third person got the following responses:
Alex:Bert is a knave.
Bert:Carl is a liar.
Carl:Alex is a knight.

What types are Alex, Bert, and Carl?

 See The Solution Submitted by Brian Smith No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer program used | Comment 2 of 6 |
The computer program I used was:

DECLARE SUB permute (a\$)
'1=Kt 2=Kv truth first 3=Kv lie first 4=L
FOR a = 1 TO 4
SELECT CASE a
CASE 1
kt = 1
CASE 2, 3
kv = 1
CASE 4
l = 1
END SELECT
FOR b = 1 TO 4
SELECT CASE b
CASE 1
kt = kt + 1
CASE 2, 3
kv = kv + 1
CASE 4
l = l + 1
END SELECT
FOR c = 1 TO 4
SELECT CASE c
CASE 1
kt = kt + 1
CASE 2, 3
kv = kv + 1
CASE 4
l = l + 1
END SELECT
s\$ = LTRIM\$(STR\$(a)) + LTRIM\$(STR\$(b)) + LTRIM\$(STR\$(c))
h\$ = s\$
DO
good = 1
SELECT CASE a
CASE 1, 2
IF c <> 4 THEN good = 0
IF b < 2 OR b > 3 THEN good = 0
CASE 3, 4
IF c = 4 THEN good = 0
IF b > 1 AND b < 4 THEN good = 0
END SELECT
SELECT CASE b
CASE 1, 2
IF a <> 1 THEN good = 0
IF c <> 4 THEN good = 0
CASE 3, 4
IF a = 1 THEN good = 0
IF c = 4 THEN good = 0
END SELECT
SELECT CASE c
CASE 1, 2
IF b < 2 OR b > 3 THEN good = 0
IF a <> 1 THEN good = 0
CASE 3, 4
IF b > 1 AND b < 4 THEN good = 0
IF a = 1 THEN good = 0
END SELECT

x = VAL(MID\$(s\$, 1, 1))
y = VAL(MID\$(s\$, 2, 1))
z = VAL(MID\$(s\$, 3, 1))

SELECT CASE x
CASE 1, 3
IF kt <> 1 THEN good = 0
CASE 2, 4
IF kt = 1 THEN good = 0
END SELECT
SELECT CASE y
CASE 1, 3
IF kv <> 1 THEN good = 0
CASE 2, 4
IF kv = 1 THEN good = 0
END SELECT
SELECT CASE z
CASE 1, 3
IF l <> 1 THEN good = 0
CASE 2, 4
IF l = 1 THEN good = 0
END SELECT

IF good THEN PRINT a, b, c: PRINT s\$

permute s\$
LOOP UNTIL s\$ = h\$
SELECT CASE c
CASE 1
kt = kt - 1
CASE 2, 3
kv = kv - 1
CASE 4
l = l - 1
END SELECT
NEXT c
SELECT CASE b
CASE 1
kt = kt - 1
CASE 2, 3
kv = kv - 1
CASE 4
l = l - 1
END SELECT
NEXT b
kt = 0: kv = 0: l = 0
NEXT a

END

with the output

4             4             3
434

the key having been given in a comment in the program:

'1=Kt 2=Kv truth first 3=Kv lie first 4=L

A, B and C were liar, liar, knave respectively, and the sequence of speaking for the middle question was liar, truth-telling knave (as he lied in the first and third questions), liar. So the only truth that was told was by Carl the Knave, to the middle question, saying that only one was a liar.

 Posted by Charlie on 2007-09-29 16:19:40

 Search: Search body:
Forums (0)