Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Write a function winner(a, b) for two moves. Rock beats scissors, scissors beats paper and paper beats rock. What are winner("rock", "scissors"), winner("paper", "scissors") and winner("paper", "paper")?
Check the draw first, then list the winning pairs with or.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Plan. Same moves: draw. Then the three winning pairs for player 1, joined with or. Everything else means player 2 wins.
rock against scissors: player 1 wins.paper against scissors: scissors beats paper, so player 2 wins.paper against paper: a draw.Log in to join the discussion.
Loading…