You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
551 B
16 lines
551 B
10 months ago
|
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))
|