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

Home > Logic > Liars and Knights
Know thy Knaves (Posted on 2007-10-09) Difficulty: 4 of 5
Alex, Bert, and Carl are taking a break from being main subjects in these logic puzzles, so Dave and Eddy decided to comment on the rarely seen Fred, Gary, and Hank.

Dave and Eddy are both knaves and each one makes four of the eight statements below. The statements are in order, but whether Dave or Eddy made any given statement is not known. Without knowing which statements are Dave's and which are Eddy's, can you determine the types of Fred, Gary, and Hank?
  1. Fred is a liar.
  2. Gary is a knave.
  3. Hank is a knight.
  4. Fred and Gary are the same type.
  5. Gary and Hank are different types.
  6. Fred is a knight.
  7. Hank is a knave.
  8. Gary is a liar.

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

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution (spoiler) | Comment 1 of 7
In the sequence of true and false statements it doesn't matter which is Dave and which is Eddy, as each is a knave.

The sequence of true and false statements, given their being spoken by two knaves, and given the content about Fred, Gary and Hank, can only be F, F, T, F, T, T, F, T.  If Dave is the first speaker, then any of the following speaker orders could produce this sequence of true and false.  Below each sequence of speaker's initials is the truth value of the statement (0 for false, 1 for true), and below that, the types for each of Fred, Gary and Hank, using n for knight and l for liar (there is no knave in the group, other than Dave and Eddy):





Also valid would be the same sequences, but with Dave and Eddy interchanged.

So Fred and Hank are knights and Gary is a liar.

DECLARE SUB permute (a$)

s$ = "dddeeee"
hld$ = s$
  seq$ = "d" + s$
  FOR f = 1 TO 3
   ft$ = MID$("nvl", f, 1)
   FOR g = 1 TO 3
    gt$ = MID$("nvl", g, 1)
    FOR h = 1 TO 3
     ht$ = MID$("nvl", h, 1)
     FOR d1 = 0 TO 1
      FOR e1 = 0 TO 1
       d = d1
       e = e1
       good = 1
       FOR q = 1 TO 8
        spkr$ = MID$(seq$, q, 1)
        IF spkr$ = "d" THEN tv = d: d = 1 - d:  ELSE tv = e: e = 1 - e
        tval$(q) = LTRIM$(STR$(tv))
        SELECT CASE q
         CASE 1
          IF ABS(ft$ = "l") <> tv THEN good = 0: EXIT FOR
         CASE 2
          IF ABS(gt$ = "v") <> tv THEN good = 0: EXIT FOR
         CASE 3
          IF ABS(ht$ = "n") <> tv THEN good = 0: EXIT FOR
         CASE 4
          IF ABS(ft$ = gt$) <> tv THEN good = 0: EXIT FOR
         CASE 5
          IF ABS(gt$ <> ht$) <> tv THEN good = 0: EXIT FOR
         CASE 6
          IF ABS(ft$ = "n") <> tv THEN good = 0: EXIT FOR
         CASE 7
          IF ABS(ht$ = "v") <> tv THEN good = 0: EXIT FOR
         CASE 8
          IF ABS(gt$ = "l") <> tv THEN good = 0: EXIT FOR
        END SELECT
       NEXT q
       IF good THEN
        PRINT seq$
        FOR i = 1 TO 8
          PRINT tval$(i);
        PRINT "fgh"
        PRINT ft$; gt$; ht$
       END IF
      NEXT e1
     NEXT d1
    NEXT h
   NEXT g
  NEXT f
  permute s$
LOOP UNTIL s$ = hld$
  Posted by Charlie on 2007-10-09 11:44:14
Please log in:
Remember me:
Sign up! | Forgot password

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

Copyright © 2002 - 2020 by Animus Pactum Consulting. All rights reserved. Privacy Information