From d2af5b8bad3d17b9f66eaf6fd528902b270f21ef Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 5 Apr 2022 14:02:10 +0200 Subject: [PATCH] lint --- 11/11.py | 1 + 11/11_2.py | 1 + 14/14.py | 1 + 14/14_2.py | 8 ++++---- 14/14_2_bad.py | 1 + 9/9.py | 1 + 9/9_2.py | 1 + 7 files changed, 10 insertions(+), 4 deletions(-) diff --git a/11/11.py b/11/11.py index e7b9b8e..6f90aee 100755 --- a/11/11.py +++ b/11/11.py @@ -30,6 +30,7 @@ def check_flash(grid, f): def flash(grid, x, y, f): + # pylint: disable=R0912 grid[y][x] = 0 f += 1 if y > 0: # upper neighbours diff --git a/11/11_2.py b/11/11_2.py index 10606fb..a6249a9 100755 --- a/11/11_2.py +++ b/11/11_2.py @@ -30,6 +30,7 @@ def check_flash(grid, f): def flash(grid, x, y, f): + # pylint: disable=R0912 grid[y][x] = 0 f += 1 if y > 0: # upper neighbours diff --git a/14/14.py b/14/14.py index 3a29e82..96edb18 100755 --- a/14/14.py +++ b/14/14.py @@ -15,6 +15,7 @@ def parse_file(file): def step_poly(poly_str, ruleset): new_p = [] + p = None for i, p in enumerate(poly_str): if i + 1 == len(poly_str): break diff --git a/14/14_2.py b/14/14_2.py index 2a5eb1f..4ef9f1e 100755 --- a/14/14_2.py +++ b/14/14_2.py @@ -53,13 +53,13 @@ for s in range(40): print(f'poly count: {poly_count}') -elements = set([k for key in poly_count.keys() for k in (key[0], key[1])]) +elements = ([k for key, value in poly_count.items() for k in (key[0], key[1])]) print(f'elements: {elements}') elem_count = dict.fromkeys(elements, 0) -for polymer in poly_count.keys(): - elem_count[polymer[0]] += poly_count[polymer] - elem_count[polymer[1]] += poly_count[polymer] +for polymer, count in poly_count.items(): + elem_count[polymer[0]] += count + elem_count[polymer[1]] += count # remove double count, and fix first and last element elem_count[first_last[0]] += 1 diff --git a/14/14_2_bad.py b/14/14_2_bad.py index e5e12b8..eb15461 100755 --- a/14/14_2_bad.py +++ b/14/14_2_bad.py @@ -15,6 +15,7 @@ def parse_file(file): def step_poly(poly_str, ruleset): new_p = [] + p = None l_poly = len(poly_str) for i, p in enumerate(poly_str): if i + 1 == l_poly: diff --git a/9/9.py b/9/9.py index eac8960..afa3872 100755 --- a/9/9.py +++ b/9/9.py @@ -21,6 +21,7 @@ def print_hmap(hmap): def find_lowpoints(hmap): + # pylint: disable=R0912 lpoints = [] # first line diff --git a/9/9_2.py b/9/9_2.py index 782cb27..488f15f 100755 --- a/9/9_2.py +++ b/9/9_2.py @@ -14,6 +14,7 @@ def parse_file(file): def find_lowpoints(hmap): + # pylint: disable=R0912 lpoints = [] # first line