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
|
||||
|
||||
with open('input.txt') as f:
|
||||
with open('input.txt', encoding="utf-8") as f:
|
||||
previous_value = int(f.readline())
|
||||
|
||||
for line in f:
|
||||
|
|
2
1/1_2.py
2
1/1_2.py
|
@ -4,7 +4,7 @@
|
|||
|
||||
count = 0
|
||||
|
||||
with open('input.txt') as f:
|
||||
with open('input.txt', encoding="utf-8") as f:
|
||||
n2_value = int(f.readline())
|
||||
n1_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
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
i = 0
|
||||
for line in f.readlines():
|
||||
chunks = []
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
def parse_file(file):
|
||||
non_corrupted = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
i = 0
|
||||
for line in f.readlines():
|
||||
chunks = []
|
||||
|
|
2
11/11.py
2
11/11.py
|
@ -5,7 +5,7 @@ GRID_SIZE = 10
|
|||
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
columns = []
|
||||
for line in f.readlines():
|
||||
columns.append([int(c) for c in line.strip()])
|
||||
|
|
|
@ -5,7 +5,7 @@ GRID_SIZE = 10
|
|||
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
columns = []
|
||||
for line in f.readlines():
|
||||
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):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
return [x.strip() for x in f.readlines()]
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
|
||||
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()]
|
||||
|
||||
|
||||
|
|
2
13/13.py
2
13/13.py
|
@ -5,7 +5,7 @@
|
|||
def parse_file(file):
|
||||
parsed_dots = []
|
||||
parsed_folds = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
for line in f.readlines():
|
||||
if line.startswith('fold along '):
|
||||
_, f = line.strip().split('fold along ')
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
def parse_file(file):
|
||||
parsed_dots = []
|
||||
parsed_folds = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
for line in f.readlines():
|
||||
if line.startswith('fold along '):
|
||||
_, f = line.strip().split('fold along ')
|
||||
|
|
2
14/14.py
2
14/14.py
|
@ -5,7 +5,7 @@ from collections import Counter
|
|||
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
poly_string = list(f.readline().strip())
|
||||
f.readline()
|
||||
insertion_rules = dict([line.strip().split(' -> ') for line in f.readlines()])
|
||||
|
|
|
@ -7,7 +7,7 @@ from collections import Counter
|
|||
def parse_file(file):
|
||||
poly_list = []
|
||||
insertion_rules = {}
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
poly_str = list(f.readline().strip())
|
||||
|
||||
for i, p in enumerate(poly_str):
|
||||
|
|
|
@ -5,7 +5,7 @@ from collections import Counter
|
|||
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
poly_string = list(f.readline().strip())
|
||||
f.readline()
|
||||
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+)')
|
||||
|
||||
with open('input.txt') as f:
|
||||
with open('input.txt', encoding="utf-8") as f:
|
||||
for line in f:
|
||||
m = re_parse.match(line)
|
||||
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+)')
|
||||
|
||||
with open('input.txt') as f:
|
||||
with open('input.txt', encoding="utf-8") as f:
|
||||
for line in f:
|
||||
m = re_parse.match(line)
|
||||
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)
|
||||
|
||||
with open('input.txt') as f:
|
||||
with open('input.txt', encoding="utf-8") as f:
|
||||
for line in f:
|
||||
m = re_parse.match(line)
|
||||
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 = []
|
||||
with open('input.txt') as f:
|
||||
with open('input.txt', encoding="utf-8") as f:
|
||||
for input_line in f:
|
||||
line_buf.append(input_line)
|
||||
|
||||
|
|
2
4/4.py
2
4/4.py
|
@ -57,7 +57,7 @@ class Board:
|
|||
|
||||
def parse_file(file):
|
||||
boards_list = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
numbers = f.readline().split(',')
|
||||
|
||||
line = f.readline()
|
||||
|
|
2
4/4_2.py
2
4/4_2.py
|
@ -57,7 +57,7 @@ class Board:
|
|||
|
||||
def parse_file(file):
|
||||
boards_list = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
numbers = f.readline().split(',')
|
||||
|
||||
line = f.readline()
|
||||
|
|
2
5/5.py
2
5/5.py
|
@ -4,7 +4,7 @@
|
|||
def parse_file(file):
|
||||
horizontal_lines = []
|
||||
vertical_lines = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
for l in f.readlines():
|
||||
p1, p2 = l.strip().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 = []
|
||||
vertical_lines = []
|
||||
diagonal_lines = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
for l in f.readlines():
|
||||
p1, p2 = l.strip().split(' -> ')
|
||||
strx1, stry1 = p1.split(',')
|
||||
|
|
2
6/6.py
2
6/6.py
|
@ -2,7 +2,7 @@
|
|||
# 2021 - Advent Of Code - 6
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
line = f.readline()
|
||||
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
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
line = f.readline()
|
||||
|
||||
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
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
line = f.readline()
|
||||
|
||||
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
|
||||
|
||||
def parse_file(file):
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
line = f.readline()
|
||||
|
||||
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):
|
||||
outs = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
for line in f.readlines():
|
||||
_, out = line.strip().split('| ')
|
||||
outs.append(out)
|
||||
|
|
2
8/8_2.py
2
8/8_2.py
|
@ -6,7 +6,7 @@
|
|||
def parse_file(file):
|
||||
numbers_list = []
|
||||
outputs = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
for line in f.readlines():
|
||||
numbers, output = line.strip().split(' | ')
|
||||
numbers_list.append(numbers)
|
||||
|
|
2
9/9.py
2
9/9.py
|
@ -3,7 +3,7 @@
|
|||
|
||||
def parse_file(file):
|
||||
hmap = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
for line in f.readlines():
|
||||
linemap = []
|
||||
for n in line.strip():
|
||||
|
|
2
9/9_2.py
2
9/9_2.py
|
@ -3,7 +3,7 @@
|
|||
|
||||
def parse_file(file):
|
||||
hmap = []
|
||||
with open(file) as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
for line in f.readlines():
|
||||
linemap = []
|
||||
for n in line.strip():
|
||||
|
|
Loading…
Reference in a new issue