You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

22 lines
462 B

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)