Author | pavankasireddi |
Submission date | 2019-06-09 04:22:01.448270 |
Rating | 1261 |
Matches played | 238 |
Win rate | 12.61 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if not input:
total_len = 5
beatthepairs = {'R':'P', 'P':'S', 'S':'R'}
total = [''] * total_len
output = random.choice("RPS")
else:
total = total[1:] + [input]
Rock_num = (total.count('R'), 'R')
Paper_num = (total.count('P'), 'P')
Scissors_num = (total.count('S'), 'S')
min_value = min(Rock_num, Paper_num, Scissors_num)[0]
min_index = [x[1] for x in [Rock_num, Paper_num, Scissors_num] if x[0] == min_value]
output = beatthepairs[random.choice(min_index)]