day 1 - part 2

This commit is contained in:
Stanislas Jouffroy 2024-12-02 16:16:06 +01:00
parent b844fafd78
commit 5f492b3f66
6 changed files with 99 additions and 22 deletions

16
2024/day1/common.py Normal file
View file

@ -0,0 +1,16 @@
from pathlib import Path
def get_lists(data_file: Path) -> tuple[list[int], list[int]]:
list1 = []
list2 = []
for line in data_file.open():
numbers = line.strip().split(" ")
list1.append(int(numbers[0]))
list2.append(int(numbers[1]))
return list1, list2
def get_ordered_lists(data_file: Path) -> tuple[list[int], list[int]]:
list1, list2 = get_lists(data_file)
return sorted(list1), sorted(list2)