testing.rps

Authorhannah
Submission date2017-12-07 22:27:58.274840
Rating3398
Matches played306
Win rate30.72

Use rpsrunner.py to play unranked matches on your computer.

Source code:

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)