| Author | hannah | 
| Submission date | 2017-12-14 14:55:31.377410 | 
| Rating | 4622 | 
| Matches played | 314 | 
| Win rate | 44.59 | 
Use rpsrunner.py to play unranked matches on your computer.
if input == "": # initialize variables for the first round
    totalCount = 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 len(moves) > 4:
    lastChars = moves[-4:]
else:
    lastChars = ""
if rockCount > paperCount and rockCount > scissorsCount:
    output = "P" # paper beats rock
elif paperCount >= scissorsCount and paperCount >= scissorsCount:
    output = "S" # scissors beats paper
else:
    output = "R" # rock beats scissors
def count_substring(STR, SUB):
    n = len(SUB)   # SUB is lastChars + R, S, or P
    if len(STR) < n:
        return 0
    occurCount = 0
    lastPosition = n-1
    firstPosition = 0
    occurCount = 0
    while lastPosition < totalCount:
        lastPosition += 1
        firstPosition += 1
        if SUB == STR[firstPosition:lastPosition]:
            occurCount += 1
    return occurCount
rockCount = count_substring(moves, lastChars+"R")
paperCount = count_substring(moves, lastChars+"P")
scissorsCount = count_substring(moves, lastChars+"S")