Created
March 9, 2012 15:22
-
-
Save mark/2006969 to your computer and use it in GitHub Desktop.
Paper Scissors Rock
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 evaluate_game(game) | |
"PSRP"[ "#{ game[0][1] }#{ game[1][1] }" ] ? game[1] : game[0] | |
end | |
def report_game(game) | |
puts "#{ game[0][0] } vs. #{ game[1][0] }" | |
puts "\tWinner = #{ evaluate_game(game)[0] }\n\n" | |
end | |
paper1 = [ "Papa Err", "P" ] | |
paper2 = [ "Popo Err", "P" ] | |
scissors1 = [ "Cut Throat", "S" ] | |
scissors2 = [ "Slice Bad", "S" ] | |
rock1 = [ "Rocksteady", "R" ] | |
rock2 = [ "Mr. Roboto", "R" ] | |
report_game([ paper1, paper2 ]) | |
report_game([ paper1, scissors2 ]) | |
report_game([ paper1, rock2 ]) | |
report_game([ scissors1, paper2 ]) | |
report_game([ scissors1, scissors2 ]) | |
report_game([ scissors1, rock2 ]) | |
report_game([ rock1, paper2 ]) | |
report_game([ rock1, scissors2 ]) | |
report_game([ rock1, rock2 ]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment