title: Manipulating arrays with recursive function
body: <pre><code>def rps_tournament_winner(tournament)
    for i in 0..1 do
      if tournament[i][1].is_a? Array then
        rps_tournament_winner(tournament[i])
      else 
        tournament=rps_game_winner(tournament)
        return
      end
    end
    return tournament
  end
  </code></pre>
  
  <p>This is a part of rock-papers-scissors implementation in Ruby </p>
  
  <pre><code>rps_game_winner
  </code></pre>
  
  <p>takes an array of two arrays in format of </p>
  
  <pre><code>[ ["Allen", "S"], ["Omer", "P"] ]
  </code></pre>
  
  <p>where first element is player's name, second element is their decision and returns the winner.</p>
  
  <pre><code>rps_tournament_winner
  </code></pre>
  
  <p>takes an input of nested arrays with arbitrary depth like</p>
  
  <pre><code>[
    [
      [ ["Armando", "P"], ["Dave", "S"] ],
      [ ["Richard", "R"], ["Michael", "S"] ],
    ],
    [
      [ ["Allen", "S"], ["Omer", "P"] ],
      [ ["David E.", "R"], ["Richard X.", "P"] ]
    ]
  ]
  </code></pre>
  
  <p>What I am trying to do is modifying the original input as the function makes progress but the input comes out as it came in. Incorporating global variables are a solution but this is a work to be graded with an auto grader and I suspect it is just going to push some input directly to the function and compare the output so its not an option. </p>