kwout 2 years ago
parent d38e9fa85b
commit 5475101d7e
  1. 22
      2021/day10/10.py
  2. 10
      2021/day10/input.txt.sample
  3. 0
      2021/day9/9.py
  4. 2
      README.md

@ -0,0 +1,22 @@
lines = open("input.txt", 'r').read().splitlines()
di = {
')': ('(', 3),
']': ('[', 57),
'}': ('{', 1197),
'>': ('<', 25137)
}
score = 0
for l in lines:
stack = []
for c in l:
if c == '(' or c == '[' or c == '{' or c == '<':
stack.append(c)
if c == ')' or c == ']' or c == '}' or c == '>':
if stack.pop() != di.get(c)[0]:
score += di.get(c)[1]
break
print(score)

@ -0,0 +1,10 @@
[({(<(())[]>[[{[]{<()<>>
[(()[<>])]({[<{<<[]>>(
{([(<{}[<>[]}>{[]{[(<()>
(((({<>}<{<{<>}{[]{[]{}
[[<[([]))<([[{}[[()]]]
[{[{({}]{}}([{[{{{}}([]
{<[[]]>}<{[{[{[]{()[[[]
[<(<(<(<{}))><([]([]()
<{([([[(<>()){}]>(<<{{
<{([{{}}[<[[[<>{}]]]>[]]

@ -1,7 +1,7 @@
my solutions for the [Advent of Code](https://adventofcode.com/)
in progress:\
2021 (python)\
2021 (python)
planned:\
2022 (rust)\

Loading…
Cancel
Save