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

Home > Logic > Liars and Knights
Hello My Name is . . . (Posted on 2007-03-06) Difficulty: 3 of 5
You have been invited to a poker game where each of the other players (Alex, Bert, Carl, Dave) is a knight, knave or liar. The players introduce themselves as follows:

Player 1's statements:
1. Bert is a knight.
2. I am Alex.

Player 2's statements:
1. Alex is a liar.
2. I am a knave.

Player 3's statements:
1. Carl is a knave.
2. Dave is a liar.

Player 4's statements:
1. I am Dave.
2. Bert is a knight.
3. Carl is a knave.

Determine who makes which set of statements and whether each one is a knight, knave or liar.

See The Solution Submitted by Brian Smith    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution As the computer does it. | Comment 3 of 8 |

DECLARE SUB permute (a$)
CLS

' 1=kt; 2=liar; 3=kv truth first; 4=kv lie first
typ$(1) = "knight"
typ$(2) = "liar"
typ$(3) = "knave starting with truth"
typ$(4) = "knave starting with lie"

n$ = "abcd"
nh$ = n$
DO
 alex = INSTR(n$, "a")
 bert = INSTR(n$, "b")
 carl = INSTR(n$, "c")
 dave = INSTR(n$, "d")
 FOR t1 = 1 TO 4
  t(1) = t1
 FOR t2 = 1 TO 4
  t(2) = t2
 FOR t3 = 1 TO 4
  t(3) = t3
 FOR t4 = 1 TO 4
  t(4) = t4

 IF bert <> 1 AND alex <> 2 AND carl <> 3 AND bert <> 4 AND carl <> 4 THEN

   IF (t(bert) = 1) = (t1 = 1 OR t1 = 3) THEN
    IF (alex = 1) = (t1 = 1 OR t1 = 4) THEN
   IF (t(alex) = 2) = (t2 = 1 OR t2 = 3) THEN
    IF (t2 > 2) = (t2 = 1 OR t2 = 4) THEN
   IF (t(carl) > 2) = (t3 = 1 OR t3 = 3) THEN
    IF (t(dave) = 2) = (t3 = 1 OR t3 = 4) THEN
   IF (dave = 4) = (t4 = 1 OR t4 = 3) THEN
    IF (t(bert) = 1) = (t4 = 1 OR t4 = 4) THEN
     IF (t(carl) > 2) = (t4 = 1 OR t4 = 3) THEN

   FOR i = 1 TO 4
     PRINT i; MID$(n$, i, 1); " "; typ$(t(i))
   NEXT
   PRINT
   ct = ct + 1

   END IF
   END IF
   END IF
   END IF
   END IF
   END IF
   END IF
   END IF
   END IF

 END IF

 NEXT
 NEXT
 NEXT
 NEXT

 permute n$
LOOP UNTIL n$ = nh$

finds

1 a knave starting with lie
2 c knave starting with lie
3 b knave starting with truth
4 d knave starting with truth

If we allow the players each to refer to himself by proper name sometimes (in addition to pronoun at other times), we get 14 solutions, by leaving out the

 IF bert <> 1 AND alex <> 2 AND carl <> 3 AND bert <> 4 AND carl <> 4 THEN

1 a knave starting with lie            1 b liar
2 b liar                               2 c knave starting with lie
3 c knave starting with truth          3 a knave starting with truth
4 d knave starting with truth          4 d knave starting with truth
1 a knave starting with lie            1 b liar
2 b knave starting with lie            2 d liar
3 c knave starting with truth          3 a knave starting with lie
4 d knave starting with truth          4 c liar
1 a knave starting with lie            1 c liar
2 c knave starting with lie            2 d liar
3 b knave starting with truth          3 a knave starting with lie
4 d knave starting with truth          4 b liar
1 a knave starting with lie            1 d liar
2 d liar                               2 a knave starting with lie
3 b knave starting with lie            3 b knave starting with lie
4 c liar                               4 c liar
1 a knave starting with lie            1 d liar
2 d knave starting with lie            2 b liar
3 b liar                               3 a knave starting with lie
4 c liar                               4 c liar
1 a knave starting with lie            1 d liar
2 d knave starting with lie            2 b knave starting with lie
3 c liar                               3 a knave starting with lie
4 b liar                               4 c liar
1 b liar                               1 d liar
2 a knave starting with lie            2 c liar
3 c knave starting with truth          3 a knave starting with lie
4 d knave starting with truth          4 b liar

  Posted by Charlie on 2007-03-06 15:55:33
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information