Files
AdventOfCode2022/02/02-01.py
2023-12-25 19:05:32 +01:00

26 lines
710 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# parse input
input_file = open("input", "r")
total_score = 0
for li in input_file:
li = li.strip().split()
# Score for my choose
if li[1] == "X":
total_score += 1
elif li[1] == "Y":
total_score += 2
elif li[1] == "Z":
total_score += 3
# Score for Draw, Win, Loose
if (li[0] == "A" and li[1] == "X") or (li[0] == "B" and li[1] == "Y") or (li[0] == "C" and li[1] == "Z"):
total_score += 3
elif (li[0] == "A" and li[1] == "Y") or (li[0] == "B" and li[1] == "Z") or (li[0] == "C" and li[1] == "X"):
total_score += 6
print(total_score)
input_file.close()
print("Lösung 1:", total_score)