I am trying to split the sub-arrays if there are more than 8. I have tried calling the rps_tournament_winner function on players if it has a flattened length longer than 16 but I get a "stack too deep error".
Do I have to work on the players variable or tournament? I'm looking for a nudge in the right direction; not a complete solution.
def rps_tournament_winner(tournament)
return rps_game_winner(tournament) if tournament.flatten.length == 4
players = tournament.flatten(2)
while players.length > 1
players = players.each_slice(2).map { |x| rps_game_winner(x) }
end
players[0]
end
tournamentin some way first.