2023-12-05 13:55:38 +01:00
|
|
|
#!/bin/python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from pprint import pprint
|
|
|
|
|
|
|
|
input_f = sys.argv[1]
|
|
|
|
|
|
|
|
seeds, *maps = open(input_f).read().split('\n\n')
|
|
|
|
|
|
|
|
seeds = seeds.split(':')[1].split()
|
|
|
|
|
2023-12-05 19:34:48 +01:00
|
|
|
#pprint(seeds)
|
|
|
|
#pprint(maps)
|
2023-12-05 13:55:38 +01:00
|
|
|
|
|
|
|
tmp_seeds = []
|
|
|
|
|
|
|
|
for i in range(0,len(seeds)-1,2):
|
|
|
|
#print('Creating range: ' + seeds[i] + ' to ' + str(int(seeds[i+1])+int(seeds[i])-1))
|
|
|
|
for j in range(int(seeds[i]),int(seeds[i+1])+int(seeds[i])):
|
|
|
|
tmp_seeds.append(j)
|
|
|
|
|
|
|
|
seeds = tmp_seeds
|
2023-12-05 19:34:48 +01:00
|
|
|
|
2023-12-06 17:38:30 +01:00
|
|
|
#count = 1000000
|
2023-12-05 19:34:48 +01:00
|
|
|
count = 0
|
2023-12-06 17:38:30 +01:00
|
|
|
#for i in range(1000000,2000000):
|
|
|
|
|
|
|
|
#maps.reverse()
|
|
|
|
for seed in range(0,50):
|
|
|
|
print("seed: " + str(seed),end="")
|
|
|
|
|
|
|
|
for i in maps:
|
|
|
|
tmp = []
|
|
|
|
i = i.split()
|
2023-12-05 13:55:38 +01:00
|
|
|
#print(i)
|
2023-12-06 17:38:30 +01:00
|
|
|
#for ldx,l in enumerate(seeds):
|
|
|
|
# l = int(l)
|
|
|
|
# count += 1
|
2023-12-05 13:55:38 +01:00
|
|
|
for x in range(2,len(i)-2,3):
|
|
|
|
d = int(i[x])
|
|
|
|
s = int(i[x+1])
|
|
|
|
r = int(i[x+2])
|
|
|
|
#print('Looking for ' + str(l) + ' in range ' + str(s) + ' > ' + str((s+r)),end='')
|
2023-12-06 17:38:30 +01:00
|
|
|
if s <= seed and seed < s + r:
|
|
|
|
seed = d + (seed - s)
|
|
|
|
print(seed)
|
2023-12-05 13:55:38 +01:00
|
|
|
break
|
2023-12-06 17:38:30 +01:00
|
|
|
else:
|
|
|
|
print()
|
2023-12-05 13:55:38 +01:00
|
|
|
#print(seeds)
|
|
|
|
"""
|
|
|
|
for i in range(0,7):
|
|
|
|
tmp = []
|
|
|
|
for j in range(2,len(nmaps[i]),3):
|
|
|
|
print("des " + str(nmaps[i][j]))
|
|
|
|
print("src " + str(nmaps[i][j+1]))
|
|
|
|
print("rng " + str(nmaps[i][j+2]))
|
|
|
|
for x in range(int(nmaps[i][j]),int(nmaps[i][j])+int(nmaps[i][j+2])):
|
|
|
|
print(x)
|
|
|
|
|
|
|
|
"""
|