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

Home > Logic
Day-knights and night-knights 8 (Posted on 2014-03-03) Difficulty: 3 of 5
There is a land where every inhabitant is either a day-knight or a night-knight. Day-knights tell the truth in the day and lie at night. Night-knights lie in the day and tell the truth at night.

Members of the Smith family are day-knights and, members of the Jones family are night-knights.

Four inhabitants Art, Barry, Cole and Dan approach a visitor to the island. It is known that precisely two of them are members of the Jones family and the remaining two are members of the Smith family.

They say:

Art: Barry’s last name is Smith.
Barry: Cole belongs to the Jones family.
Cole: Art and Dan are from different families.
Dan: Art and Barry are from the same family.

What are the surnames of the three inhabitants? Is it day or night?

No Solution Yet Submitted by K Sengupta    
No Rating

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

DECLARE SUB permute (a$)
CLS
a$ = "ssjj": h$ = a$   '  for Art Barry Cole and Dan respectively
' s=smith-day; j=jones-night
DO
  FOR day = 0 TO 1
    truth$ = MID$("sj", 2 - day, 1)
    good = 1
    IF (MID$(a$, 1, 1) = truth$) <> (MID$(a$, 2, 1) = "s") THEN good = 0
    IF (MID$(a$, 2, 1) = truth$) <> (MID$(a$, 3, 1) = "j") THEN good = 0
    IF (MID$(a$, 3, 1) = truth$) <> (MID$(a$, 1, 1) <> MID$(a$, 4, 1)) THEN good = 0
    IF (MID$(a$, 4, 1) = truth$) <> (MID$(a$, 1, 1) = MID$(a$, 2, 1)) THEN good = 0
    IF good THEN PRINT MID$("dn", 2 - day, 1); "  "; a$
  NEXT
 
  permute a$
LOOP UNTIL a$ = h$

finds

d  jjss

meaning it is daytime and Art and Barry are Joneses and Cole and Dan are Smiths.


  Posted by Charlie on 2014-03-03 13:17:00
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 (0)
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