From 9d365951e6f2c9522d4bf448d49e928e540c498f Mon Sep 17 00:00:00 2001 From: Max Wilson Date: Fri, 10 Dec 2021 07:03:36 +0000 Subject: [PATCH] sorted out day 10 part 1. easy peasy. --- 10/10.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 10/10.py diff --git a/10/10.py b/10/10.py new file mode 100644 index 0000000..94267a0 --- /dev/null +++ b/10/10.py @@ -0,0 +1,21 @@ +expectedouts = {"[" : "]", "{" : "}", "(" : ")", "<" : ">"} +outscores = {")" : 3, "]" : 57, "}" : 1197, ">": 25137} +chunkstack = [] +totalscore = 0 + +while True: + newline = input() + if newline == '': + break + readline = list(newline) + while len(readline) > 0: + currentitem = readline.pop(0) + if currentitem in expectedouts.keys(): + chunkstack.append(currentitem) + else: + lastopener = chunkstack.pop() + if currentitem != expectedouts[lastopener]: + print(newline + " - Expected " + expectedouts[lastopener] + ", but found " + currentitem + "instead.") + totalscore += outscores[currentitem] + +print(str(totalscore)) \ No newline at end of file