Skip to content

Commit

Permalink
Day 10, with some _reduction_
Browse files Browse the repository at this point in the history
  • Loading branch information
Atvars Karro committed Dec 10, 2021
1 parent cee2ab0 commit 7b6a7a6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions day10.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from functools import reduce
data = open("data/day10.txt", "r").read().splitlines()

val = {
Expand All @@ -21,10 +22,7 @@
try:
s += next(val[i] for i in d if i in ">}])")
except StopIteration:
sc = 0
for v in d[::-1]:
sc = sc * 5 + val[v]
inc.append(sc)
inc.append(reduce(lambda a, b: a * 5 + b, [val[v] for v in d[::-1]]))

inc = sorted(inc)

Expand Down

0 comments on commit 7b6a7a6

Please sign in to comment.