Skip to content

Instantly share code, notes, and snippets.

@ozzyjohnson
Created May 18, 2015 00:58
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 ozzyjohnson/bf4f8f3e85affabdafa5 to your computer and use it in GitHub Desktop.
Save ozzyjohnson/bf4f8f3e85affabdafa5 to your computer and use it in GitHub Desktop.
hello world coin flips
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