Last active
August 29, 2015 14:07
-
-
Save RemyPorter/a75fedc1b31d2f408816 to your computer and use it in GitHub Desktop.
Modeling the Gods Puzzle: http://io9.com/can-you-solve-the-worlds-other-hardest-logic-puzzle-1645422530/all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
choices = ["da","ja"] | |
truth = random.choice(choices) | |
false =[c for c in choices if c != truth] | |
false = false[0] | |
gods = [lambda: truth, lambda: false, lambda: random.choice(choices)] | |
a = random.choice(gods) | |
b = a | |
while b == a: | |
b = random.choice(gods) | |
c = a | |
while c == a or c == b: | |
c = random.choice(gods) | |
# at this point, a, b, and c are randomly selected gods. Each returns "ja", or "da", to mean true or false, but that's also random |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment