[ create a new paste ] login | about

Link: http://codepad.org/9ep13uFN    [ raw code | output | fork ]

Ruby, pasted on Mar 3:
class WrongNumberOfPlayersError < StandardError ; end
class NoSuchStrategyError < StandardError ; end

def rps_game_winner(game)
  raise WrongNumberOfPlayersError unless game.length == 2
  # your code here
end

def rps_tournament_winner(tournament)
  # your code here
end

game = [ [ "Armando", "P" ], [ "Dave", "S" ] ]

tournament = [
[
[ ["Armando", "P"], ["Dave", "S"] ],
[ ["Richard", "R"],  ["Michael", "S"] ],
],
[ 
[ ["Allen", "S"], ["Omer", "P"] ],
[ ["David E.", "R"], ["Richard X.", "P"] ]
]
]

puts rps_game_winner(game).inspect
puts '  Should Be ["Dave", "S"]'

puts rps_tournament_winner(tournament).inspect
puts '  Should Be ["Richard","R"]'


Output:
1
2
3
4
nil
  Should Be ["Dave", "S"]
nil
  Should Be ["Richard","R"]


Create a new paste based on this one


Comments: