diff --git a/1/1.py b/1/1.py index e6a4807..25b83e0 100755 --- a/1/1.py +++ b/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: diff --git a/1/1_2.py b/1/1_2.py index ba663ba..0407f03 100755 --- a/1/1_2.py +++ b/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()) diff --git a/10/10.py b/10/10.py index f948f45..bb471c7 100755 --- a/10/10.py +++ b/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 = [] diff --git a/10/10_2.py b/10/10_2.py index d29d1fa..4ade614 100755 --- a/10/10_2.py +++ b/10/10_2.py @@ -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 = [] diff --git a/11/11.py b/11/11.py index ec06d9f..e7b9b8e 100755 --- a/11/11.py +++ b/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()]) diff --git a/11/11_2.py b/11/11_2.py index 1549523..10606fb 100755 --- a/11/11_2.py +++ b/11/11_2.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()]) diff --git a/12/12.py b/12/12.py index 782ce96..e6250f1 100755 --- a/12/12.py +++ b/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()] diff --git a/12/12_2.py b/12/12_2.py index bab9e92..2ee4eea 100755 --- a/12/12_2.py +++ b/12/12_2.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()] diff --git a/13/13.py b/13/13.py index 07a35ef..3e67374 100755 --- a/13/13.py +++ b/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 ') diff --git a/13/13_2.py b/13/13_2.py index 7a9bc9b..5e521fa 100755 --- a/13/13_2.py +++ b/13/13_2.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 ') diff --git a/14/14.py b/14/14.py index 9f03472..3a29e82 100755 --- a/14/14.py +++ b/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()]) @@ -38,7 +38,7 @@ print(f'rules: {rules}') for s in range(13): print(f'step: {s}') poly = step_poly(poly, rules) - #print(poly) + # print(poly) print(Counter(poly)) c = Counter(poly).most_common()[0][1] - Counter(poly).most_common()[-1][1] diff --git a/14/14_2.py b/14/14_2.py index 9eb17ca..2a5eb1f 100755 --- a/14/14_2.py +++ b/14/14_2.py @@ -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): diff --git a/14/14_2_bad.py b/14/14_2_bad.py index 1273dc7..e5e12b8 100755 --- a/14/14_2_bad.py +++ b/14/14_2_bad.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()]) diff --git a/2/2.py b/2/2.py index 0f655cd..e4ab5bd 100755 --- a/2/2.py +++ b/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)) diff --git a/2/2_2.py b/2/2_2.py index d39ed4d..ea4db76 100755 --- a/2/2_2.py +++ b/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)) diff --git a/3/3.py b/3/3.py index 2e0d232..ab59341 100755 --- a/3/3.py +++ b/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 diff --git a/3/3_2.py b/3/3_2.py index 7a44adb..3dabad3 100755 --- a/3/3_2.py +++ b/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) diff --git a/4/4.py b/4/4.py index 3f3b21f..699a3aa 100755 --- a/4/4.py +++ b/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() diff --git a/4/4_2.py b/4/4_2.py index b15c705..2a6b59e 100755 --- a/4/4_2.py +++ b/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() diff --git a/5/5.py b/5/5.py index f676b47..88fcc96 100755 --- a/5/5.py +++ b/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(',') diff --git a/5/5_2.py b/5/5_2.py index 8360a15..99ce445 100755 --- a/5/5_2.py +++ b/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(',') diff --git a/6/6.py b/6/6.py index ba3e31e..2104628 100755 --- a/6/6.py +++ b/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(',')] diff --git a/6/6_2.py b/6/6_2.py index 378ea69..cf4d138 100755 --- a/6/6_2.py +++ b/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(',')] diff --git a/7/7.py b/7/7.py index 0ac4844..6210d6a 100755 --- a/7/7.py +++ b/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(',')] diff --git a/7/7_2.py b/7/7_2.py index 4852ebb..a4090b0 100755 --- a/7/7_2.py +++ b/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(',')] diff --git a/8/8.py b/8/8.py index ea341bc..bd90146 100755 --- a/8/8.py +++ b/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) diff --git a/8/8_2.py b/8/8_2.py index 8563a69..194af08 100755 --- a/8/8_2.py +++ b/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) diff --git a/9/9.py b/9/9.py index 05a228e..eac8960 100755 --- a/9/9.py +++ b/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(): diff --git a/9/9_2.py b/9/9_2.py index 23e6276..782cb27 100755 --- a/9/9_2.py +++ b/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():