Created
December 17, 2018 13:06
-
-
Save Pharaoh00/356c3658544906f96559da146b3c216a to your computer and use it in GitHub Desktop.
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
def beats(one, two): | |
result = False | |
# Only two outcome can occur | |
# If you Win = True | |
# If you Lose = False | |
# This is the boolean logic (George Boole created this on 1854) | |
# BEFORE all the computer stuff. Cool right? | |
if one is two: | |
return "Tie" | |
elif one is "rock": | |
if two is "paper": # Rock Lose from paper | |
return False | |
elif two is "scissors": # Rock win from scissors | |
return True | |
elif one is "paper": | |
if two is "rock": # Paper lose from rock | |
return False | |
elif two is "scissors": # Paper win from scissors | |
return True | |
elif one is "scissors": | |
if two is "rock": # Scissors lose from rock | |
return False | |
elif two is "paper": # Scissors win from paper | |
return True | |
# Do you see a pattern? | |
# You are repeating yourself. | |
print(beats("rock", "paper")) # I'll print False | |
print(beats("rock", "scissors")) # I'll print True | |
print(beats("paper", "rock")) # I'll print False | |
print(beats("paper", "scissors")) # I'll print True | |
print(beats("scissors", "rock")) # I'll print False | |
print(beats("scissors", "paper")) # I'll print True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment