Test linter and fix pycharm's style warning
This commit is contained in:
parent
7bf8952928
commit
3d87fab334
1 changed files with 5 additions and 6 deletions
11
10/10.py
11
10/10.py
|
@ -5,7 +5,6 @@ def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
i = 0
|
i = 0
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
count_open = {'(': 0, '[': 0, '{': 0, '<': 0}
|
|
||||||
chunks = []
|
chunks = []
|
||||||
for c in line.strip():
|
for c in line.strip():
|
||||||
if c in close_sign.values(): # open signs
|
if c in close_sign.values(): # open signs
|
||||||
|
@ -17,9 +16,9 @@ def parse_file(file):
|
||||||
count_score[c] += 1
|
count_score[c] += 1
|
||||||
|
|
||||||
|
|
||||||
close_sign = {')': '(', ']': '[' , '}': '{', '>': '<'}
|
close_sign = {')': '(', ']': '[', '}': '{', '>': '<'}
|
||||||
count_score = {')': 0, ']': 0, '}': 0, '>':0}
|
count_score = {')': 0, ']': 0, '}': 0, '>': 0}
|
||||||
score_table = {')': 3, ']': 57, '}': 1197, '>':25137}
|
score_table = {')': 3, ']': 57, '}': 1197, '>': 25137}
|
||||||
|
|
||||||
|
|
||||||
# parse_file('input_example.txt')
|
# parse_file('input_example.txt')
|
||||||
|
@ -28,7 +27,7 @@ parse_file('input.txt')
|
||||||
|
|
||||||
print(f'char score {count_score}')
|
print(f'char score {count_score}')
|
||||||
score = 0
|
score = 0
|
||||||
for c in close_sign:
|
for sign in close_sign:
|
||||||
score += count_score[c] * score_table[c]
|
score += count_score[sign] * score_table[sign]
|
||||||
|
|
||||||
print(f'score: {score}')
|
print(f'score: {score}')
|
||||||
|
|
Loading…
Reference in a new issue