From f85949f85266768ec1bd5e3d150e4ac71feabcf1 Mon Sep 17 00:00:00 2001 From: boredpasta Date: Mon, 13 Jan 2025 07:00:52 +0200 Subject: Add project files --- 2022/02/a.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 2022/02/a.py (limited to '2022/02/a.py') diff --git a/2022/02/a.py b/2022/02/a.py new file mode 100644 index 0000000..1338bbf --- /dev/null +++ b/2022/02/a.py @@ -0,0 +1,43 @@ +points = 0 +p = {"lost": 0, "draw": 3, "won": 6} +p2 = {"X": 1, "Y": 2, "Z": 3} + +sym = {"X": "A", "Y": "B", "Z": "C"} +sym2 = {"A": "X", "B": "Y", "C": "Z"} + +wins = {"C": "X", "A": "Y", "B": "Z"} +wins2 = {"A": "Z", "B": "X", "C": "Y"} + +trans = {"me": {"X": "R", "Y": "P", "Z": "S"}, + "enem": {"A": "R", "B": "P", "C": "S"} + } + +with open("input") as f: + lines = f.readlines() + + +for line in lines: + enem, me = line.split(" ") + enem = enem.strip() + me = me.strip() + print(enem, me) + if me == "X": + me = wins2[enem] + elif me == "Y": + me = sym2[enem] + elif me == "Z": + me = wins[enem] + if (sym[me] == enem): + points = points + p["draw"] + p2[me] + elif (me == "X" and enem == "C"): + points = points + p["won"] + p2[me] + elif (me == "Y" and enem == "A"): + points = points + p["won"] + p2[me] + elif (me == "Z" and enem == "B"): + points = points + p["won"] + p2[me] + else: + points += p2[me] + print(enem, me) + print(points) + print() +print(points) -- cgit v1.2.3