Skip to content

Commit fc96fa5

Browse files
Added 2024 solutions
1 parent 53608d1 commit fc96fa5

21 files changed

+4791
-0
lines changed

2024/01/input.txt

Lines changed: 1000 additions & 0 deletions
Large diffs are not rendered by default.

2024/01/main.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from collections import Counter
2+
3+
with open('input.txt', 'r') as f:
4+
data = f.read().strip().splitlines()
5+
first, second = [], []
6+
for x in data:
7+
x = [int(y) for y in x.split(' ')]
8+
first.append(x[0])
9+
second.append(x[1])
10+
11+
12+
first.sort()
13+
second.sort()
14+
15+
total = 0
16+
for each in zip(first, second):
17+
total += abs(each[0] - each[1])
18+
19+
print(total)
20+
counter = Counter(second)
21+
total = 0
22+
for x in first:
23+
total += x * counter[x]
24+
25+
print(total)

2024/01/test.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3 4
2+
4 3
3+
2 5
4+
1 3
5+
3 9
6+
3 3

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy