This commit is contained in:
parent
26313578e3
commit
327c6a1394
10 changed files with 16 additions and 34 deletions
4
12/12.py
4
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):
|
||||
|
|
|
@ -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):
|
||||
|
|
8
3/3_2.py
8
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])
|
||||
|
|
2
4/4.py
2
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)}')
|
||||
|
|
11
4/4_2.py
11
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 ;-) """
|
||||
|
|
2
6/6.py
2
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
|
||||
|
|
4
8/8.py
4
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}')
|
||||
|
|
4
8/8_2.py
4
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')
|
||||
|
|
4
9/9.py
4
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()
|
||||
|
||||
|
|
7
9/9_2.py
7
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 = []
|
||||
|
||||
|
|
Loading…
Reference in a new issue