Debug day5/part2_time_hog.py
Now Yielding correct result, not in a timely manner, though
This commit is contained in:
@@ -4,7 +4,7 @@ from data import extract
|
||||
import concurrent.futures
|
||||
|
||||
def seed_to_location(seed, maps):
|
||||
print(seed)
|
||||
#print(seed)
|
||||
soil_maps = list(filter(lambda soil_map: soil_map.is_mapped(seed), maps["seed-to-soil"]))
|
||||
soil = seed if soil_maps == [] else soil_maps[0].mapped_value(seed)
|
||||
fertilizer_maps = list(filter(lambda fertilizer_map: fertilizer_map.is_mapped(soil), maps["soil-to-fertilizer"]))
|
||||
@@ -24,14 +24,15 @@ def seed_to_location(seed, maps):
|
||||
|
||||
def parallel_loop(seeds, maps, index):
|
||||
lowest_location = None
|
||||
for seed_idx in range(seeds[index]):
|
||||
for seed_idx in range(seeds[index + 1]):
|
||||
seed = seeds[index] + seed_idx
|
||||
location = seed_to_location(seed, maps)
|
||||
if lowest_location is not None:
|
||||
lowest_location = min(lowest_location, location)
|
||||
else:
|
||||
lowest_location = location
|
||||
seeds, maps = extract("input.txt")
|
||||
return lowest_location
|
||||
seeds, maps = extract("example_input.txt")
|
||||
print(seeds)
|
||||
|
||||
|
||||
@@ -42,5 +43,5 @@ with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
||||
minimums.append(minimum)
|
||||
|
||||
|
||||
|
||||
minimums = map(lambda x: x.result(), minimums)
|
||||
print(min(minimums))
|
||||
|
||||
Reference in New Issue
Block a user