From b73be6a8387296db440a17e5d7006b3c14b7c151 Mon Sep 17 00:00:00 2001 From: kwout Date: Sat, 11 Feb 2023 12:53:24 -0500 Subject: [PATCH] minor improvement to readability of 10 --- 2021/day10/10.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/2021/day10/10.py b/2021/day10/10.py index 41c85e2..2b7aeb8 100644 --- a/2021/day10/10.py +++ b/2021/day10/10.py @@ -16,8 +16,9 @@ for l in lines: if c == '(' or c == '[' or c == '{' or c == '<': stack.append(c) if c == ')' or c == ']' or c == '}' or c == '>': - if stack.pop() != [x[0] for x in di if x[1] == c][0][0]: - score1 += [x for x in di if x[1] == c][0][2] + match = [x for x in di if x[1] == c][0] + if stack.pop() != match[0]: + score1 += match[2] valid = False break if valid: