Created
          June 19, 2012 05:02 
        
      - 
      
- 
        Save chadwickdonald/2952380 to your computer and use it in GitHub Desktop. 
    rock scissors paper
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def game(two_players) | |
| two_players.inject do |player1, player2| | |
| p1 = player1[1].upcase | |
| p2 = player2[1].upcase | |
| if p1 == p2 | |
| "It's a Tie!" | |
| elsif p1 == "R" && p2 =="P" | |
| player2 | |
| elsif p1 == "R" && p2 == "S" | |
| player1 | |
| elsif p1 == "P" && p2 == "R" | |
| player1 | |
| elsif p1 == "P" && p2 == "S" | |
| player2 | |
| elsif p1 == "S" && p2 == "R" | |
| player2 | |
| elsif p1 == "S" && p2 == "P" | |
| player1 | |
| end | |
| end | |
| end | |
| def find_winner(tournament) | |
| tournament.inject do |group1, group2| | |
| p group1 | |
| puts "...." | |
| p group2 | |
| end | |
| end | |
| # p game([["Lachy", "s"], ["Tony", "p"]]) | |
| find_winner([[[["Shereef", "P"], ["Lachy", "S"]], [["Robert", "R"], ["Tony", "S"]]], | |
| [[["Tanner", "S"], ["Jesse", "P"]], [["Anne", "R"], ["Jeremy", "P"]]]]) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment