This commit is contained in:
parent
5aacd6cff1
commit
ba86d90e98
29 changed files with 30 additions and 30 deletions
2
1/1.py
2
1/1.py
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
with open('input.txt') as f:
|
with open('input.txt', encoding="utf-8") as f:
|
||||||
previous_value = int(f.readline())
|
previous_value = int(f.readline())
|
||||||
|
|
||||||
for line in f:
|
for line in f:
|
||||||
|
|
2
1/1_2.py
2
1/1_2.py
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
with open('input.txt') as f:
|
with open('input.txt', encoding="utf-8") as f:
|
||||||
n2_value = int(f.readline())
|
n2_value = int(f.readline())
|
||||||
n1_value = int(f.readline())
|
n1_value = int(f.readline())
|
||||||
n_value = int(f.readline())
|
n_value = int(f.readline())
|
||||||
|
|
2
10/10.py
2
10/10.py
|
@ -2,7 +2,7 @@
|
||||||
# 2021 - Advent Of Code - 10
|
# 2021 - Advent Of Code - 10
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
i = 0
|
i = 0
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
chunks = []
|
chunks = []
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
non_corrupted = []
|
non_corrupted = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
i = 0
|
i = 0
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
chunks = []
|
chunks = []
|
||||||
|
|
2
11/11.py
2
11/11.py
|
@ -5,7 +5,7 @@ GRID_SIZE = 10
|
||||||
|
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
columns = []
|
columns = []
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
columns.append([int(c) for c in line.strip()])
|
columns.append([int(c) for c in line.strip()])
|
||||||
|
|
|
@ -5,7 +5,7 @@ GRID_SIZE = 10
|
||||||
|
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
columns = []
|
columns = []
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
columns.append([int(c) for c in line.strip()])
|
columns.append([int(c) for c in line.strip()])
|
||||||
|
|
2
12/12.py
2
12/12.py
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
return [x.strip() for x in f.readlines()]
|
return [x.strip() for x in f.readlines()]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
return [x.strip() for x in f.readlines()]
|
return [x.strip() for x in f.readlines()]
|
||||||
|
|
||||||
|
|
||||||
|
|
2
13/13.py
2
13/13.py
|
@ -5,7 +5,7 @@
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
parsed_dots = []
|
parsed_dots = []
|
||||||
parsed_folds = []
|
parsed_folds = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if line.startswith('fold along '):
|
if line.startswith('fold along '):
|
||||||
_, f = line.strip().split('fold along ')
|
_, f = line.strip().split('fold along ')
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
parsed_dots = []
|
parsed_dots = []
|
||||||
parsed_folds = []
|
parsed_folds = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if line.startswith('fold along '):
|
if line.startswith('fold along '):
|
||||||
_, f = line.strip().split('fold along ')
|
_, f = line.strip().split('fold along ')
|
||||||
|
|
4
14/14.py
4
14/14.py
|
@ -5,7 +5,7 @@ from collections import Counter
|
||||||
|
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
poly_string = list(f.readline().strip())
|
poly_string = list(f.readline().strip())
|
||||||
f.readline()
|
f.readline()
|
||||||
insertion_rules = dict([line.strip().split(' -> ') for line in f.readlines()])
|
insertion_rules = dict([line.strip().split(' -> ') for line in f.readlines()])
|
||||||
|
@ -38,7 +38,7 @@ print(f'rules: {rules}')
|
||||||
for s in range(13):
|
for s in range(13):
|
||||||
print(f'step: {s}')
|
print(f'step: {s}')
|
||||||
poly = step_poly(poly, rules)
|
poly = step_poly(poly, rules)
|
||||||
#print(poly)
|
# print(poly)
|
||||||
|
|
||||||
print(Counter(poly))
|
print(Counter(poly))
|
||||||
c = Counter(poly).most_common()[0][1] - Counter(poly).most_common()[-1][1]
|
c = Counter(poly).most_common()[0][1] - Counter(poly).most_common()[-1][1]
|
||||||
|
|
|
@ -7,7 +7,7 @@ from collections import Counter
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
poly_list = []
|
poly_list = []
|
||||||
insertion_rules = {}
|
insertion_rules = {}
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
poly_str = list(f.readline().strip())
|
poly_str = list(f.readline().strip())
|
||||||
|
|
||||||
for i, p in enumerate(poly_str):
|
for i, p in enumerate(poly_str):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from collections import Counter
|
||||||
|
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
poly_string = list(f.readline().strip())
|
poly_string = list(f.readline().strip())
|
||||||
f.readline()
|
f.readline()
|
||||||
insertion_rules = dict([line.strip().split(' -> ') for line in f.readlines()])
|
insertion_rules = dict([line.strip().split(' -> ') for line in f.readlines()])
|
||||||
|
|
2
2/2.py
2
2/2.py
|
@ -8,7 +8,7 @@ y = 0
|
||||||
|
|
||||||
re_parse = re.compile(r'(forward|up|down) (\d+)')
|
re_parse = re.compile(r'(forward|up|down) (\d+)')
|
||||||
|
|
||||||
with open('input.txt') as f:
|
with open('input.txt', encoding="utf-8") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
m = re_parse.match(line)
|
m = re_parse.match(line)
|
||||||
direction, unit = m.group(1), int(m.group(2))
|
direction, unit = m.group(1), int(m.group(2))
|
||||||
|
|
2
2/2_2.py
2
2/2_2.py
|
@ -9,7 +9,7 @@ aim = 0
|
||||||
|
|
||||||
re_parse = re.compile(r'(forward|up|down) (\d+)')
|
re_parse = re.compile(r'(forward|up|down) (\d+)')
|
||||||
|
|
||||||
with open('input.txt') as f:
|
with open('input.txt', encoding="utf-8") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
m = re_parse.match(line)
|
m = re_parse.match(line)
|
||||||
direction, unit = m.group(1), int(m.group(2))
|
direction, unit = m.group(1), int(m.group(2))
|
||||||
|
|
2
3/3.py
2
3/3.py
|
@ -9,7 +9,7 @@ result = [0] * 12
|
||||||
|
|
||||||
re_parse = re.compile(r'(\d)'*12)
|
re_parse = re.compile(r'(\d)'*12)
|
||||||
|
|
||||||
with open('input.txt') as f:
|
with open('input.txt', encoding="utf-8") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
m = re_parse.match(line)
|
m = re_parse.match(line)
|
||||||
line_count += 1
|
line_count += 1
|
||||||
|
|
2
3/3_2.py
2
3/3_2.py
|
@ -58,7 +58,7 @@ def filter_freq(buffer, freq_buf, mode):
|
||||||
|
|
||||||
|
|
||||||
line_buf = []
|
line_buf = []
|
||||||
with open('input.txt') as f:
|
with open('input.txt', encoding="utf-8") as f:
|
||||||
for input_line in f:
|
for input_line in f:
|
||||||
line_buf.append(input_line)
|
line_buf.append(input_line)
|
||||||
|
|
||||||
|
|
2
4/4.py
2
4/4.py
|
@ -57,7 +57,7 @@ class Board:
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
boards_list = []
|
boards_list = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
numbers = f.readline().split(',')
|
numbers = f.readline().split(',')
|
||||||
|
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
|
|
2
4/4_2.py
2
4/4_2.py
|
@ -57,7 +57,7 @@ class Board:
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
boards_list = []
|
boards_list = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
numbers = f.readline().split(',')
|
numbers = f.readline().split(',')
|
||||||
|
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
|
|
2
5/5.py
2
5/5.py
|
@ -4,7 +4,7 @@
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
horizontal_lines = []
|
horizontal_lines = []
|
||||||
vertical_lines = []
|
vertical_lines = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
for l in f.readlines():
|
for l in f.readlines():
|
||||||
p1, p2 = l.strip().split(' -> ')
|
p1, p2 = l.strip().split(' -> ')
|
||||||
strx1, stry1 = p1.split(',')
|
strx1, stry1 = p1.split(',')
|
||||||
|
|
2
5/5_2.py
2
5/5_2.py
|
@ -5,7 +5,7 @@ def parse_file(file):
|
||||||
horizontal_lines = []
|
horizontal_lines = []
|
||||||
vertical_lines = []
|
vertical_lines = []
|
||||||
diagonal_lines = []
|
diagonal_lines = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
for l in f.readlines():
|
for l in f.readlines():
|
||||||
p1, p2 = l.strip().split(' -> ')
|
p1, p2 = l.strip().split(' -> ')
|
||||||
strx1, stry1 = p1.split(',')
|
strx1, stry1 = p1.split(',')
|
||||||
|
|
2
6/6.py
2
6/6.py
|
@ -2,7 +2,7 @@
|
||||||
# 2021 - Advent Of Code - 6
|
# 2021 - Advent Of Code - 6
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
return [int(x) for x in line.split(',')]
|
return [int(x) for x in line.split(',')]
|
||||||
|
|
||||||
|
|
2
6/6_2.py
2
6/6_2.py
|
@ -2,7 +2,7 @@
|
||||||
# 2021 - Advent Of Code - 6 part 2
|
# 2021 - Advent Of Code - 6 part 2
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
|
|
||||||
list_state = [int(x) for x in line.split(',')]
|
list_state = [int(x) for x in line.split(',')]
|
||||||
|
|
2
7/7.py
2
7/7.py
|
@ -2,7 +2,7 @@
|
||||||
# 2021 - Advent Of Code - 7
|
# 2021 - Advent Of Code - 7
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
|
|
||||||
list_state = [int(x) for x in line.split(',')]
|
list_state = [int(x) for x in line.split(',')]
|
||||||
|
|
2
7/7_2.py
2
7/7_2.py
|
@ -2,7 +2,7 @@
|
||||||
# 2021 - Advent Of Code - 7 part 2
|
# 2021 - Advent Of Code - 7 part 2
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
|
|
||||||
list_state = [int(x) for x in line.split(',')]
|
list_state = [int(x) for x in line.split(',')]
|
||||||
|
|
2
8/8.py
2
8/8.py
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
outs = []
|
outs = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
_, out = line.strip().split('| ')
|
_, out = line.strip().split('| ')
|
||||||
outs.append(out)
|
outs.append(out)
|
||||||
|
|
2
8/8_2.py
2
8/8_2.py
|
@ -6,7 +6,7 @@
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
numbers_list = []
|
numbers_list = []
|
||||||
outputs = []
|
outputs = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
numbers, output = line.strip().split(' | ')
|
numbers, output = line.strip().split(' | ')
|
||||||
numbers_list.append(numbers)
|
numbers_list.append(numbers)
|
||||||
|
|
2
9/9.py
2
9/9.py
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
hmap = []
|
hmap = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
linemap = []
|
linemap = []
|
||||||
for n in line.strip():
|
for n in line.strip():
|
||||||
|
|
2
9/9_2.py
2
9/9_2.py
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
def parse_file(file):
|
def parse_file(file):
|
||||||
hmap = []
|
hmap = []
|
||||||
with open(file) as f:
|
with open(file, encoding="utf-8") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
linemap = []
|
linemap = []
|
||||||
for n in line.strip():
|
for n in line.strip():
|
||||||
|
|
Loading…
Reference in a new issue