Skip to content

Instantly share code, notes, and snippets.

@KoaxialKable
Last active August 29, 2015 14:24
Show Gist options
  • Save KoaxialKable/74503b5f1576a237b65d to your computer and use it in GitHub Desktop.
Save KoaxialKable/74503b5f1576a237b65d to your computer and use it in GitHub Desktop.
Very simple demonstration of the logic behind the "Two Guardians" riddle from The Labyrinth, the bool argument is the [unknown] true state of the door in question. Because the nature of each guardian is applied to the answer, we are guaranteed exactly one logical "not" and therefore should accept the opposite of our answer as the truth.
def liar(answer):
return !answer
def honest(answer):
return answer
#"Would that door say that this is the door to the castle?"
#if asking the liar, and the liar is the death door:
print(liar(honest(false))) # "True"
#if asking the liar, and the liar is the castle door:
print(liar(honest(true))) # "False"
#if asking the honest door, and the honest door is the death door:
print(honest(liar(false))) # "True"
#if asking the honest door, and the honest door is the castle door:
print(honest(liar(true))) # "False"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment