Author | hannah |
Submission date | 2017-12-07 22:27:58.274840 |
Rating | 3398 |
Matches played | 306 |
Win rate | 30.72 |
Use rpsrunner.py to play unranked matches on your computer.
if input == "": # initialize variables for the first round
rockCount = paperCount = scissorsCount = 0
moves = ""
elif input == "R":
rockCount += 1
moves = moves + "R"
elif input == "P":
paperCount += 1
moves = moves + "P"
elif input == "S":
scissorsCount += 1
moves += "S"
if rockCount > paperCount and rockCount > scissorsCount:
output = "P" # paper beats rock
elif paperCount > scissorsCount:
output = "S" # scissors beats paper
else:
output = "R" # rock beats scissors
def count_substring(STR, SUB):
n = len(SUB)
if len(STR) < n:
return 0
elif str[0:n] == SUB:
return 1 + count_substring(str[1:], SUB)
else:
return count_substring(str[1:], SUB)