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

Home > Logic > Liars and Knights
Liars Logic (Posted on 2014-03-13) Difficulty: 3 of 5
You find yourself on the Island of Knights, Knaves and Liars, where a race has just finished. Each of the five participants, who are all different ages, is either a Knight (who always tells the truth), a Liar (who always lies), or a Knave (who alternates between true and false statements, though their first statement may be either true or false).

Each of the five competitors makes the following statements to you. Figure out their type (Knight, Knave, or Liar), their relative ages, and the order in which they finished the race.

Adam says:

Bart is a Liar.
Earl is a Liar.
I'm older than Chad.
I'm younger than Bart.
I finished ahead of Dave.
I finished ahead of Earl.
The oldest person came in 4th place.

Bart says:

Chad is a Liar.
Adam is a Liar.
I'm older than Dave.
I'm younger than Chad.
I finished ahead of Earl.
I finished ahead of Adam.
The 5th oldest person came in 3rd place.

Chad says:

Dave is a Liar.
Bart is a Liar.
I'm older than Earl.
I'm younger than Dave.
I finished ahead of Adam.
I finished ahead of Bart.
The 4th oldest person came in 1st place.

Dave says:

Earl is a Liar.
Chad is a Liar.
I'm older than Adam.
I'm younger than Earl.
I finished ahead of Bart.
I finished ahead of Chad.
The 3rd oldest person came in 2nd place.

Earl says:

Adam is a Liar.
Dave is a Liar.
I'm older than Bart.
I'm younger than Adam.
I finished ahead of Chad.
I finished ahead of Dave.
The 2nd oldest person came in 5th place.

See The Solution Submitted by tomarken    
Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 1 of 1

DECLARE SUB permute (a$)
CLS
FOR At = 0 TO 3 'Liar, Kv-2nd true, Kv-1st true, Kt
 a1 = -(At \ 2): a2 = -(At MOD 2)
FOR Bt = 0 TO 3
 b1 = -(Bt \ 2): b2 = -(Bt MOD 2)
FOR Ct = 0 TO 3
 c1 = -(Ct \ 2): c2 = -(Ct MOD 2)
FOR Dt = 0 TO 3
 d1 = -(Dt \ 2): d2 = -(Dt MOD 2)
FOR Et = 0 TO 3
 e1 = -(Et \ 2): e2 = -(Et MOD 2)

good = 1
IF a1 <> (Bt = 0) THEN good = 0
IF a2 <> (Et = 0) THEN good = 0
IF b1 <> (Ct = 0) THEN good = 0
IF b2 <> (At = 0) THEN good = 0
IF c1 <> (Dt = 0) THEN good = 0
IF c2 <> (Bt = 0) THEN good = 0
IF d1 <> (Et = 0) THEN good = 0
IF d2 <> (Ct = 0) THEN good = 0
IF e1 <> (At = 0) THEN good = 0
IF e2 <> (Dt = 0) THEN good = 0
IF good THEN
 
  age$ = "ABCDE": ah$ = age$
  DO
    good = 1
    IF a1 <> (INSTR(age$, "A") > INSTR(age$, "C")) THEN good = 0
    IF a2 <> (INSTR(age$, "A") < INSTR(age$, "B")) THEN good = 0
    IF b1 <> (INSTR(age$, "B") > INSTR(age$, "D")) THEN good = 0
    IF b2 <> (INSTR(age$, "B") < INSTR(age$, "C")) THEN good = 0
    IF c1 <> (INSTR(age$, "C") > INSTR(age$, "E")) THEN good = 0
    IF c2 <> (INSTR(age$, "C") < INSTR(age$, "D")) THEN good = 0
    IF d1 <> (INSTR(age$, "D") > INSTR(age$, "A")) THEN good = 0
    IF d2 <> (INSTR(age$, "D") < INSTR(age$, "E")) THEN good = 0
    IF e1 <> (INSTR(age$, "E") > INSTR(age$, "B")) THEN good = 0
    IF e2 <> (INSTR(age$, "E") < INSTR(age$, "A")) THEN good = 0
      IF good THEN
  place$ = "ABCDE": ph$ = place$
  DO
    good = 1
    IF a1 <> (INSTR(place$, "A") < INSTR(place$, "D")) THEN good = 0
    IF a2 <> (INSTR(place$, "A") < INSTR(place$, "E")) THEN good = 0
    IF b1 <> (INSTR(place$, "B") < INSTR(place$, "E")) THEN good = 0
    IF b2 <> (INSTR(place$, "B") < INSTR(place$, "A")) THEN good = 0
    IF c1 <> (INSTR(place$, "C") < INSTR(place$, "A")) THEN good = 0
    IF c2 <> (INSTR(place$, "C") < INSTR(place$, "B")) THEN good = 0
    IF d1 <> (INSTR(place$, "D") < INSTR(place$, "B")) THEN good = 0
    IF d2 <> (INSTR(place$, "D") < INSTR(place$, "C")) THEN good = 0
    IF e1 <> (INSTR(place$, "E") < INSTR(place$, "C")) THEN good = 0
    IF e2 <> (INSTR(place$, "E") < INSTR(place$, "D")) THEN good = 0
      IF good THEN
        IF a1 <> (MID$(age$, 5, 1) = MID$(place$, 4, 1)) THEN good = 0
        IF b1 <> (MID$(age$, 1, 1) = MID$(place$, 3, 1)) THEN good = 0
        IF c1 <> (MID$(age$, 2, 1) = MID$(place$, 1, 1)) THEN good = 0
        IF d1 <> (MID$(age$, 3, 1) = MID$(place$, 2, 1)) THEN good = 0
        IF e1 <> (MID$(age$, 4, 1) = MID$(place$, 5, 1)) THEN good = 0
          IF good THEN
            PRINT "A="; At, "B="; Bt, "C="; Ct, "D="; Dt, "E="; Et
            PRINT "youngest "; age$; " oldest"
            PRINT "place: "; place$; " first to last"
          END IF
      END IF
    permute place$
  LOOP UNTIL place$ = ph$
      END IF
    permute age$
  LOOP UNTIL age$ = ah$


END IF

NEXT
NEXT
NEXT
NEXT
NEXT

finds

A= 0          B= 1          C= 2          D= 0          E= 3
youngest BEDAC oldest
place: EBCDA first to last

meaning

Adam was a liar.
Bart was a knave, who started by telling a lie.
Chad was a knave, who started by telling the truth.
Dave was a liar.
Earl was a knight.

From youngest to oldest: Bart, Earl, Dave, Adam and Chad.
Order of finish: Earl, Bart, Chad, Dave and Adam.


  Posted by Charlie on 2014-03-13 19:18:44
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 (16)
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