fork download
  1. def rps_game_winner(game)
  2. case (game[0][1])
  3. when 'R'
  4. puts "#{game[0][0]} wins" if game[1][1]='S'
  5. puts "#{game[1][0]} wins" if game[1][1]='P'
  6. puts "#{game[0][0]} wins" if game[1][1]='R'
  7. when 'P'
  8. puts "#{game[0][0]} wins" if game[1][1]='R'
  9. puts "#{game[1][0]} wins" if game[1][1]='S'
  10. puts "#{game[0][0]} wins" if game[1][1]='P'
  11. when 'S'
  12. puts "#{game[0][0]} wins" if game[1][1]='P'
  13. puts "#{game[1][0]} wins" if game[1][1]='R'
  14. puts "#{game[0][0]} wins" if game[1][1]='S'
  15. end
  16. end
  17. rps_game_winner([[ "Armando", "P" ], [ "Dave", "S" ]])
Success #stdin #stdout 0s 4760KB
stdin
Standard input is empty
stdout
Armando wins
Dave wins
Armando wins