Advent of Code Solutions Thread: Day Two

Only shitty solutions allowed

38
Jump in the discussion.

No email address required.

>Only shitty submissions allowed

def UpdateScore(x, choice, total):
    score = 0
    if choice == "R":
        score+=1
        if x == "A":
            score+=3
        elif x == "C":
            score+=6
        return (total+score)
    elif choice == "P":
        score+=2
        if x == "A":
            score+=6
        elif x == "B":
            score+=3
        return (total+score)
    elif choice == "S":
        score+=3
        if x == "B":
            score+=6
        elif x == "C":
            score+=3
        return (total+score)

guide=open("Day 2.txt", "r")
total = 0
for x in guide:
    if x[0] == "A":
        if x[2] == "X":
            total = UpdateScore(x[0], "S", total)
        elif x[2] == "Y":
            total = UpdateScore(x[0], "R", total)
        elif x[2] == "Z":
            total = UpdateScore(x[0], "P", total)
    if x[0] == "B":
        if x[2] == "X":
            total = UpdateScore(x[0], "R", total)
        elif x[2] == "Y":
            total = UpdateScore(x[0], "P", total)
        elif x[2] == "Z":
            total = UpdateScore(x[0], "S", total)
    if x[0] == "C":
        if x[2] == "X":
            total = UpdateScore(x[0], "P", total)
        elif x[2] == "Y":
            total = UpdateScore(x[0], "S", total)
        elif x[2] == "Z":
            total = UpdateScore(x[0], "R", total)
print(total)
Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.