Skip to content

Instantly share code, notes, and snippets.

@mark
Created March 9, 2012 15:22
Show Gist options
  • Save mark/2006969 to your computer and use it in GitHub Desktop.
Save mark/2006969 to your computer and use it in GitHub Desktop.
Paper Scissors Rock
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