Skip to content

Commit

Permalink
sorted out day 10 part 1. easy peasy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Wilson committed Dec 10, 2021
1 parent bee25ab commit 9d36595
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 10/10.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 9d36595

Please sign in to comment.