NYT Emulator 1.1

This program has been disqualified.


AuthorMike Bufardeci
Submission date2011-06-13 09:20:29.925877
Rating6201
Matches played637
Win rate64.05

Source code:

'''
This program attempts to emulate the New York Times RPS program.
It can be found at:
https://www.nytimes.com/interactive/science/rock-paper-scissors.html
'''
def search(history,l):
    if l < 1:
        return "S"
    if l >= len(history):
        return search(history,l-1)
    last = []
    last.extend(history[len(history)-l:])
    match = []
    i = 0
    while i < len(history)-l:
        if history[i:i+l] == last:
            match.append(history[i+l])
        i += 1
    if match == []:
        return search(history,l-1)
    maxi = ("P", match.count("R"))
    if match.count("P") > maxi[1]:
        maxi = ("S", match.count("P"))
    if match.count("S") > maxi[1]:
        maxi = ("R", match.count("S"))
    return maxi[0]
if input:
    history.append(input)   
else:
    history = []
output = search(history, 10)