def score_match(x, y): if x == "A": if y == "X": return 3 if y == "Y": return 6 else: return 0 if x == "B": if y == "X": return 0 if y == "Y": return 3 else: return 6 else: if y == "X": return 6 if y == "Y": return 0 else: return 3 def score(x): if x == "X": return 1 if x == "Y": return 2 else: return 3 f = open("input.txt", "r") lines = f.read().splitlines() current = 0 for line in lines: x, y = line.split(" ") current = current + score(y) + score_match(x, y) print(current)