Skip to content

Instantly share code, notes, and snippets.

@MikaelCarpenter
Created November 21, 2016 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikaelCarpenter/b828ec82ce5636847526cdb7eb9feddb to your computer and use it in GitHub Desktop.
Save MikaelCarpenter/b828ec82ce5636847526cdb7eb9feddb to your computer and use it in GitHub Desktop.
Warmup Problem #3

Problem

You are shipwrecked on an unknown island where there are two kinds of people - Knights & Knaves. Knights always tell the truth and knaves always lie. To survive, you need to know who is who.

For each person in the following scenarios, can you figure out if they are a knight or a knave? Support your answer with a logical justification / proof.

1. Persons: A & B

  • A says: “B is a knave.”
  • B says: “We are both knights.”

2. Persons: A & B

  • A says: “We are both knights."
  • B says: “We are both knaves.”

3. Persons: A, B & C

  • A says: “B is a knave.”
  • B says: “C is a knave.”
  • C says: “B and myself are knights.”

4. Persons: A & B

  • A says: “At least one of the two of us is a knight.”
  • B says: “La la la!”

Answer

1. If B is a Knight, then A's statement would be impossible. Therefor B is a Knave. That makes A a Knight.

2. A can't be telling the truth, because then B can't say what he did. So A must be a Knave. However, if B is a Knave, then his statement is then true making it impossible as well, so B can't be a Knave if A is as well, however he can't be a Knight either because then his statement is a lie. If you try to nail down B first then A ends up in the situation where they can't be either, so this is an impossible situation in a Knight and Knave only world.

3. If C is telling the truth, then it would be impossible for B to say what he did because it's a lie. So C must be a Knave. Then B is therefore a Knight, making A a Knave as well.

4. A is a knight then B can be a Knight or a Knave. If A is a Knave, B is also a Knave, but can't tell which is the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment