Skip to content

Instantly share code, notes, and snippets.

@walkermatt
Created December 17, 2016 09:21
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 walkermatt/b40f2182fe3b0ad1aed35ff5799d4318 to your computer and use it in GitHub Desktop.
Save walkermatt/b40f2182fe3b0ad1aed35ff5799d4318 to your computer and use it in GitHub Desktop.
Rock, paper, scissors created by walkermatt - https://repl.it/EsHd/15
# 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