diff --git a/10/10.py b/10/10.py index ecda15f..f948f45 100755 --- a/10/10.py +++ b/10/10.py @@ -5,7 +5,6 @@ def parse_file(file): with open(file) as f: i = 0 for line in f.readlines(): - count_open = {'(': 0, '[': 0, '{': 0, '<': 0} chunks = [] for c in line.strip(): if c in close_sign.values(): # open signs @@ -17,9 +16,9 @@ def parse_file(file): count_score[c] += 1 -close_sign = {')': '(', ']': '[' , '}': '{', '>': '<'} -count_score = {')': 0, ']': 0, '}': 0, '>':0} -score_table = {')': 3, ']': 57, '}': 1197, '>':25137} +close_sign = {')': '(', ']': '[', '}': '{', '>': '<'} +count_score = {')': 0, ']': 0, '}': 0, '>': 0} +score_table = {')': 3, ']': 57, '}': 1197, '>': 25137} # parse_file('input_example.txt') @@ -28,7 +27,7 @@ parse_file('input.txt') print(f'char score {count_score}') score = 0 -for c in close_sign: - score += count_score[c] * score_table[c] +for sign in close_sign: + score += count_score[sign] * score_table[sign] print(f'score: {score}')