From 2e144c1d89d2bf84f7d13d75a9e48e3d0177567c Mon Sep 17 00:00:00 2001 From: Emma Nora Theuer Date: Sun, 8 Dec 2024 22:04:43 +0100 Subject: [PATCH] Rename to accurately describe the content --- Day1/solution.py | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 Day1/solution.py diff --git a/Day1/solution.py b/Day1/solution.py deleted file mode 100644 index 595528d..0000000 --- a/Day1/solution.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -from typing import List - -class Solution: - def __init__(self) -> None: - self.lines: List[str] = [] - self.left_array: List[int] = [] - self.right_array: List[int] = [] - self.result: int = 0 - - def read(self) -> None: - with open("input") as f: - self.lines = f.readlines() - - def clean(self) -> None: - for i in range(len(self.lines)): - self.lines[i] = self.lines[i].strip() - - def split_lines(self) -> None: - for line in self.lines: - elements: List[str] = line.split() - clean_element: int = int(elements[0]) - self.left_array.append(clean_element) - clean_element: int = int(elements[1]) - self.right_array.append(clean_element) - - def sort_lists(self) -> None: - self.left_array.sort() - self.right_array.sort() - - def calculate_difference(self) -> None: - for i in range(len(self.left_array)): - difference: int = abs(self.right_array[i] - self.left_array[i]) - self.result += difference - - -def main() -> None: - solver: Solution = Solution() - solver.read() - solver.clean() - solver.split_lines() - solver.sort_lists() - solver.calculate_difference() - print(solver.result) - -if __name__ == "__main__": - main()