2023 day 5 part 1 solved

master
kwout 11 months ago
parent 7e8d944d0d
commit e9f829a6a8
  1. 2
      2023/3.py
  2. 16
      2023/5.py

@ -1,4 +1,4 @@
lines = [i for i in open("input.txt", 'r').read().splitlines()] lines = open("input.txt", 'r').read().splitlines()
sum = 0 sum = 0
sum2 = 0 sum2 = 0

@ -0,0 +1,16 @@
data = open("input.txt", 'r').read().split("\n\n")
seeds = [int(i) for i in data[0][7:].split()]
maps = [[[int(i) for i in numb.split()] for numb in block.splitlines()[1:]] for block in data[1:]]
#[destinationStart, sourceStart, length]
for m in maps:
newSeeds = list(seeds)
for line in m:
target, source, length = line
for i in range(len(seeds)):
seed = seeds[i]
if seed in range(source, source+length):
newSeeds[i] = seed + (target - source)
seeds = newSeeds
print(min(newSeeds))
Loading…
Cancel
Save