parent
949a0aa1e7
commit
37938613b9
3 changed files with 23 additions and 1 deletions
@ -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) |
Loading…
Reference in new issue