Editor

Rock, Paper, Scissors Tally

#225 · Simulation · Beginner · 30 XP · about 6 min

Ana and Ben played rock, paper, scissors all afternoon and wrote down every throw. ana and ben are strings of the same length: ana[i] and ben[i] are what each of them threw in round i, as 'R' (rock), 'P' (paper) or 'S' (scissors).

Rock beats scissors, scissors beats paper, and paper beats rock. Two equal throws are a draw. Write rps_tally(ana, ben) that returns a tuple (ana_wins, ben_wins, draws): how many rounds Ana won, how many Ben won and how many nobody won.

Examples

rps_tally('RPS', 'SPR')    # returns (1, 1, 1)
rps_tally('RRRR', 'PPPP')  # returns (0, 4, 0)
rps_tally('', '')          # returns (0, 0, 0)

In the first example Ana's rock beats Ben's scissors, both throw paper, and Ben's rock beats Ana's scissors.

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.