Created
May 18, 2015 00:58
-
-
Save ozzyjohnson/bf4f8f3e85affabdafa5 to your computer and use it in GitHub Desktop.
hello world coin flips
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 sys | |
import itertools | |
for test in itertools.product([False,True], repeat=2): | |
bob_flip = test[0] | |
alice_flip = test[1] | |
if bob_flip == False: | |
bob_guess = True | |
else: | |
bob_guess = False | |
if alice_flip == False: | |
alice_guess = False | |
else: | |
alice_guess = True | |
if alice_guess == bob_flip or bob_guess == alice_flip: | |
print "Bob's Flip: " + str(bob_flip) | |
print "Alice's Flip: " + str(alice_flip) | |
print "Bob's Guess: " + str(bob_guess) | |
print "Alice's Guess: " + str(alice_guess) | |
print "Passed." | |
else: | |
print "Failed." | |
sys.exit() | |
print "Finished without fail." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment