Author | Gary |
Submission date | 2019-02-04 17:28:58.812390 |
Rating | 5138 |
Matches played | 249 |
Win rate | 46.59 |
Use rpsrunner.py to play unranked matches on your computer.
R = 0;
P = 0;
S = 0;
str = []
if input == "": # initialize variables for the first round
R = P = S = 0
elif input == "R":
R += 1
str.append("R")
elif input == "P":
P += 1
str.append("P")
elif input == "S":
S += 1
str.append("S")
temp=""
if(len(str)>=9):
temp = str.pop(0)
elif temp == "R":
R -= 1
elif temp == "P":
P -= 1
elif temp == "S":
S -= 1
if R > P and R > S:
if temp != "P":
output = "P" # paper beats rock
else:
output = "S"
elif P > S:
if temp != "S":
output = "S" # scissors beats paper
else:
output = "R"
else:
if temp != "R":
output = "R" # rock beats scissors
else:
output = "P"