Rock Paper Scissors

Easy~10 min

Given two strings player1 and player2 representing moves in a game of Rock Paper Scissors, determine the result from player 1's perspective.

Each move is one of: "rock", "paper", or "scissors".

The rules are:

  • Rock beats scissors
  • Scissors beats paper
  • Paper beats rock

Return "win" if player 1 wins, "lose" if player 1 loses, or "draw" if both players chose the same move.

Examples

Example 1
Input: player1 = "rock", player2 = "scissors"
Output: "win"
Explanation: Rock beats scissors, so player 1 wins.
Example 2
Input: player1 = "scissors", player2 = "rock"
Output: "lose"
Explanation: Rock beats scissors, so player 1 loses.
Example 3
Input: player1 = "paper", player2 = "paper"
Output: "draw"
Explanation: Both players chose the same move.

Constraints

  • player1 and player2 are each one of "rock", "paper", or "scissors".
  • Inputs are always lowercase.
Code
Ctrl+EnterRun|Ctrl+⇧+EnterSubmit
Output

Run your code to see results

Use Cmd+Enter to run