From 327c6a1394467d60a0ed74d12f79cd53e98e47b5 Mon Sep 17 00:00:00 2001 From: kleph Date: Mon, 13 Dec 2021 05:38:24 +0100 Subject: [PATCH] Lint --- 12/12.py | 4 +--- 12/12_2.py | 4 +--- 3/3_2.py | 8 +++++--- 4/4.py | 2 ++ 4/4_2.py | 11 ----------- 6/6.py | 2 +- 8/8.py | 4 ++-- 8/8_2.py | 4 ++-- 9/9.py | 4 ++-- 9/9_2.py | 7 ------- 10 files changed, 16 insertions(+), 34 deletions(-) diff --git a/12/12.py b/12/12.py index 60204af..782ce96 100755 --- a/12/12.py +++ b/12/12.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -# 2021 - Advent Of Code - 11 - -GRID_SIZE = 10 +# 2021 - Advent Of Code - 12 def parse_file(file): diff --git a/12/12_2.py b/12/12_2.py index e401838..bab9e92 100755 --- a/12/12_2.py +++ b/12/12_2.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -# 2021 - Advent Of Code - 11 - -GRID_SIZE = 10 +# 2021 - Advent Of Code - 12 part 2 def parse_file(file): diff --git a/3/3_2.py b/3/3_2.py index d4c1f7c..7a44adb 100755 --- a/3/3_2.py +++ b/3/3_2.py @@ -33,10 +33,12 @@ def freq_bits(buf, mode): if mode == MOST: return oxy - elif mode == LEAST: + if mode == LEAST: co2_freq = [0 if x == 1 else 1 for x in oxy] return co2_freq + return None + def filter_pos(line_buffer, position, value): for line in line_buffer: @@ -57,8 +59,8 @@ def filter_freq(buffer, freq_buf, mode): line_buf = [] with open('input.txt') as f: - for line in f: - line_buf.append(line) + for input_line in f: + line_buf.append(input_line) gamma_count = freq_bits(line_buf, MOST) gamma_bin = "".join([str(x) for x in gamma_count]) diff --git a/4/4.py b/4/4.py index 9abf2a8..3f3b21f 100755 --- a/4/4.py +++ b/4/4.py @@ -85,6 +85,8 @@ def play_until_win(boards_list, draws): board.print_with_mark() return board, d + return None, None + boards, calls = parse_file('input.txt') print(f'number of boards: {len(boards)}') diff --git a/4/4_2.py b/4/4_2.py index d3541be..b15c705 100755 --- a/4/4_2.py +++ b/4/4_2.py @@ -75,17 +75,6 @@ def parse_file(file): return boards_list, numbers -def play_until_win(boards_list, draws): - """ play until win and return last pos """ - - for d in draws: - for board in boards_list: - if board.mark_number(d): - print("this board wins !") - board.print_with_mark() - return board, d - - def play(boards_list, draws): """ call all numbers could stop when all boards have won ;-) """ diff --git a/6/6.py b/6/6.py index bb8f882..ba3e31e 100755 --- a/6/6.py +++ b/6/6.py @@ -9,7 +9,7 @@ def parse_file(file): def iterate(state): new_fish = 0 - for i in range(len(state)): + for i, _ in enumerate(state): if state[i] == 0: new_fish += 1 state[i] = 6 diff --git a/8/8.py b/8/8.py index 43a0bbd..ea341bc 100755 --- a/8/8.py +++ b/8/8.py @@ -5,7 +5,7 @@ def parse_file(file): outs = [] with open(file) as f: for line in f.readlines(): - nums, out = line.strip().split('| ') + _, out = line.strip().split('| ') outs.append(out) return outs @@ -19,7 +19,7 @@ for o in outputs: words = o.split(' ') for w in words: length = len(w) - if length == 2 or length == 3 or length == 4 or length == 7: + if length in (2, 3, 4, 7): count += 1 print(f'{count}') diff --git a/8/8_2.py b/8/8_2.py index c059c3b..8563a69 100755 --- a/8/8_2.py +++ b/8/8_2.py @@ -15,10 +15,10 @@ def parse_file(file): return numbers_list, outputs -def print_numbers(id): +def print_numbers(id_num): print('identified numbers:') for i in range(10): - print(f'{i} is {id[i]}') + print(f'{i} is {id_num[i]}') # entries, displays = parse_file('input_example1.txt') diff --git a/9/9.py b/9/9.py index c9e4845..05a228e 100755 --- a/9/9.py +++ b/9/9.py @@ -14,8 +14,8 @@ def parse_file(file): def print_hmap(hmap): - for y in range(len(hmap)): - for x in range(len(hmap[y])): + for y, _ in enumerate(hmap): + for x, _ in enumerate(hmap[y]): print(hmap[y][x], end='') print() diff --git a/9/9_2.py b/9/9_2.py index ad8965c..23e6276 100755 --- a/9/9_2.py +++ b/9/9_2.py @@ -13,13 +13,6 @@ def parse_file(file): return hmap -def print_hmap(hmap): - for y in range(len(hmap)): - for x in range(len(hmap[y])): - print(hmap[y][x], end='') - print() - - def find_lowpoints(hmap): lpoints = []