Lint
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
kleph 2021-12-13 05:38:24 +01:00
parent 26313578e3
commit 327c6a1394
10 changed files with 16 additions and 34 deletions

View file

@ -1,7 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# 2021 - Advent Of Code - 11 # 2021 - Advent Of Code - 12
GRID_SIZE = 10
def parse_file(file): def parse_file(file):

View file

@ -1,7 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# 2021 - Advent Of Code - 11 # 2021 - Advent Of Code - 12 part 2
GRID_SIZE = 10
def parse_file(file): def parse_file(file):

View file

@ -33,10 +33,12 @@ def freq_bits(buf, mode):
if mode == MOST: if mode == MOST:
return oxy return oxy
elif mode == LEAST: if mode == LEAST:
co2_freq = [0 if x == 1 else 1 for x in oxy] co2_freq = [0 if x == 1 else 1 for x in oxy]
return co2_freq return co2_freq
return None
def filter_pos(line_buffer, position, value): def filter_pos(line_buffer, position, value):
for line in line_buffer: for line in line_buffer:
@ -57,8 +59,8 @@ def filter_freq(buffer, freq_buf, mode):
line_buf = [] line_buf = []
with open('input.txt') as f: with open('input.txt') as f:
for line in f: for input_line in f:
line_buf.append(line) line_buf.append(input_line)
gamma_count = freq_bits(line_buf, MOST) gamma_count = freq_bits(line_buf, MOST)
gamma_bin = "".join([str(x) for x in gamma_count]) gamma_bin = "".join([str(x) for x in gamma_count])

2
4/4.py
View file

@ -85,6 +85,8 @@ def play_until_win(boards_list, draws):
board.print_with_mark() board.print_with_mark()
return board, d return board, d
return None, None
boards, calls = parse_file('input.txt') boards, calls = parse_file('input.txt')
print(f'number of boards: {len(boards)}') print(f'number of boards: {len(boards)}')

View file

@ -75,17 +75,6 @@ def parse_file(file):
return boards_list, numbers 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): def play(boards_list, draws):
""" call all numbers """ call all numbers
could stop when all boards have won ;-) """ could stop when all boards have won ;-) """

2
6/6.py
View file

@ -9,7 +9,7 @@ def parse_file(file):
def iterate(state): def iterate(state):
new_fish = 0 new_fish = 0
for i in range(len(state)): for i, _ in enumerate(state):
if state[i] == 0: if state[i] == 0:
new_fish += 1 new_fish += 1
state[i] = 6 state[i] = 6

4
8/8.py
View file

@ -5,7 +5,7 @@ def parse_file(file):
outs = [] outs = []
with open(file) as f: with open(file) as f:
for line in f.readlines(): for line in f.readlines():
nums, out = line.strip().split('| ') _, out = line.strip().split('| ')
outs.append(out) outs.append(out)
return outs return outs
@ -19,7 +19,7 @@ for o in outputs:
words = o.split(' ') words = o.split(' ')
for w in words: for w in words:
length = len(w) length = len(w)
if length == 2 or length == 3 or length == 4 or length == 7: if length in (2, 3, 4, 7):
count += 1 count += 1
print(f'{count}') print(f'{count}')

View file

@ -15,10 +15,10 @@ def parse_file(file):
return numbers_list, outputs return numbers_list, outputs
def print_numbers(id): def print_numbers(id_num):
print('identified numbers:') print('identified numbers:')
for i in range(10): 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') # entries, displays = parse_file('input_example1.txt')

4
9/9.py
View file

@ -14,8 +14,8 @@ def parse_file(file):
def print_hmap(hmap): def print_hmap(hmap):
for y in range(len(hmap)): for y, _ in enumerate(hmap):
for x in range(len(hmap[y])): for x, _ in enumerate(hmap[y]):
print(hmap[y][x], end='') print(hmap[y][x], end='')
print() print()

View file

@ -13,13 +13,6 @@ def parse_file(file):
return hmap 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): def find_lowpoints(hmap):
lpoints = [] lpoints = []