init
This commit is contained in:
commit
ca9736d8ec
122 files changed
+28514
No files matched your search
@@ -0,0 +1,42 @@
|
||||
with open('input.text', 'r') as file:
|
||||
data: list[str] = file.readlines()
|
||||
|
||||
# Parse Input
|
||||
|
||||
left = []
|
||||
right = []
|
||||
|
||||
for line in data:
|
||||
nums = line.split()
|
||||
|
||||
left.append(int(nums[0]))
|
||||
right.append(int(nums[1]))
|
||||
|
||||
# Part 1
|
||||
|
||||
lc = left.copy()
|
||||
rc = right.copy()
|
||||
|
||||
total = 0
|
||||
while min(lc) != float('inf'):
|
||||
lowest_left = min(lc)
|
||||
lowest_right = min(rc)
|
||||
|
||||
total += abs(lowest_left - lowest_right)
|
||||
|
||||
lc[lc.index(lowest_left)] = float('inf')
|
||||
rc[rc.index(lowest_right)] = float('inf')
|
||||
|
||||
print(f'Part 1: {total}')
|
||||
|
||||
# Part 2
|
||||
|
||||
lc = left.copy()
|
||||
rc = right.copy()
|
||||
|
||||
while min(lc) != float('inf'):
|
||||
lowest_left = min(lc)
|
||||
lowest_right = min(rc)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user