From a7aa40381e3a70279d4d5074d62aaec350178be3 Mon Sep 17 00:00:00 2001 From: kwout Date: Sun, 1 Dec 2024 13:22:31 -0500 Subject: [PATCH] 2024 day 1 solved --- 2024/1.py | 16 ++++++++++++++++ README.md | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 2024/1.py diff --git a/2024/1.py b/2024/1.py new file mode 100644 index 0000000..5b03712 --- /dev/null +++ b/2024/1.py @@ -0,0 +1,16 @@ +list1, list2, summa, summa2 = [], [], 0, 0 + +for l in open("input.txt", 'r').read().splitlines(): + tup = [int(n) for n in l.split(' ')] + list1.append(tup[0]) + list2.append(tup[1]) + +list1.sort() +list2.sort() + +for i in range(len(list1)): + summa += abs(list1[i] - list2[i]) + summa2 += list2.count(list1[i]) * list1[i] + +print(summa) +print(summa2) \ No newline at end of file diff --git a/README.md b/README.md index 34c0d2d..0404cc8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ my solutions for the [Advent of Code](https://adventofcode.com/) in progress:\ 2021: 12/25\ 2022: 8/25\ -2023: 9/25 +2023: 9/25\ +2024: 0/25 planned:\ 2020\