minor improvement to readability of 10

master
kwout 2 years ago
parent 42b2aa13b5
commit 52b8b62b91
  1. 5
      2021/day10/10.py

@ -16,8 +16,9 @@ for l in lines:
if c == '(' or c == '[' or c == '{' or c == '<': if c == '(' or c == '[' or c == '{' or c == '<':
stack.append(c) stack.append(c)
if c == ')' or c == ']' or c == '}' or c == '>': if c == ')' or c == ']' or c == '}' or c == '>':
if stack.pop() != [x[0] for x in di if x[1] == c][0][0]: match = [x for x in di if x[1] == c][0]
score1 += [x for x in di if x[1] == c][0][2] if stack.pop() != match[0]:
score1 += match[2]
valid = False valid = False
break break
if valid: if valid:

Loading…
Cancel
Save