Created
December 17, 2016 09:21
-
-
Save walkermatt/b40f2182fe3b0ad1aed35ff5799d4318 to your computer and use it in GitHub Desktop.
Rock, paper, scissors created by walkermatt - https://repl.it/EsHd/15
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
# Rock, paper, scissors | |
def beats(thing1, thing2): | |
""" Determine who wins rock, paper, scissors | |
by passing each players choice """ | |
if thing1 == thing2: | |
# Draw, both players chose the same thing | |
return None | |
# Determine which thing beats thing2 | |
victors = { | |
"rock": "scissors", | |
"paper": "rock", | |
"scissors": "paper" | |
} | |
victor = victors[thing2] | |
return victor == thing1 | |
# Tests | |
assert beats("rock", "paper") == True | |
assert beats("rock", "rock") == None | |
assert beats("scissors", "paper") == False | |
print "All assets pass!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment