commit eae5d96cf4370c71ee9eb282dfdf875cce496e87 Author: kirbylife Date: Sat Nov 30 23:17:31 2024 -0600 Day 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e427dd8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*/input.txt diff --git a/day-1/main.py b/day-1/main.py new file mode 100644 index 0000000..32a1121 --- /dev/null +++ b/day-1/main.py @@ -0,0 +1,27 @@ +def parse_input() -> tuple[list[int], list[int]]: + raw_input = open("input.txt").read() + + line1 = [] + line2 = [] + + for raw_line in raw_input.splitlines(): + num1, num2 = raw_line.split() + line1.append(int(num1)) + line2.append(int(num2)) + return line1, line2 + +def main() -> int: + line1, line2 = parse_input() + line1.sort() + line2.sort() + + distances = [abs(num1 - num2) for num1, num2 in zip(line1, line2)] + + result = sum(distances) + + print(result) + + return 0 + +if __name__ == "__main__": + main()