Problem 165122 · easy · Level 01 Prerequisites & Setup

Rock, Paper, Scissors Referee

conditionals · strings · boolean logic

Two players each choose "rock", "paper" or "scissors". Write rps_winner(p1, p2) that returns "draw" if they chose the same thing, "player 1" if the first player wins, and "player 2" otherwise. Rock beats scissors, scissors beats paper, paper beats rock.

Examples

Input:  p1 = "rock", p2 = "scissors"
Output: "player 1"

Input:  p1 = "paper", p2 = "paper"
Output: "draw"

Input:  p1 = "rock", p2 = "paper"
Output: "player 2"

Constraints

  • both inputs are exactly one of "rock", "paper", "scissors"

Goals

  • Compare two strings
  • Express a set of winning combinations with and/or
Starting Python…