diff --git a/day5/part2_time_hog.py b/day5/part2_time_hog.py index 698c708..bdcb7ee 100755 --- a/day5/part2_time_hog.py +++ b/day5/part2_time_hog.py @@ -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)) diff --git a/q b/q new file mode 100644 index 0000000..f25b94c --- /dev/null +++ b/q @@ -0,0 +1,75 @@ +commit 028c13fbba8bb94d3cad5d5d5d6509923c6be082 (HEAD -> main) +Author: Fedaya +Date: Wed Dec 6 22:00:00 2023 +0100 + + Revert "Debugging of Day5/part2_time_hog.py" + + This reverts commit bf7aac3b22c1e777a13674535ea4a869392acb12. + +commit bf7aac3b22c1e777a13674535ea4a869392acb12 +Author: Étienne Gille +Date: Wed Dec 6 21:58:35 2023 +0100 + + Debugging of Day5/part2_time_hog.py + + It now works in parallel, not in a timely manner, though + +commit 8b2bac07914217eb8b57798e4d0f798953e8db9d (origin/main, origin/HEAD) +Author: Fedaya +Date: Wed Dec 6 08:12:32 2023 +0100 + + Day 6 completed + + Day5 part 2 still ongoing + +commit b588eeb7e5cc84aa6c61791ff7612edfc0116bb9 +Author: Fedaya +Date: Tue Dec 5 08:06:53 2023 +0100 + + First solution to part2 + + It's kind of a time hog, though + +commit e46a2717b4c062a7d1bcf92f018a4c91538a9fcc +Author: Fedaya +Date: Tue Dec 5 07:18:55 2023 +0100 + + Day 5 part1 completed + + Also, deleted an example_input.txt, modified .gitignore + added a script to get the current day's input + +commit 9ee98d375a929dd8b690e50f4b62e8b3460fdd8b +Author: Fedaya +Date: Mon Dec 4 07:47:34 2023 +0100 + + Modified .gitignore to not include example_input.txt + +commit 142696bf6e92ce3e97de220f03c0b57c2b9c0f2a +Author: Fedaya +Date: Mon Dec 4 07:44:36 2023 +0100 + + Day 4 completed + + + refactored day 1 to 3 with black -l 119 + +commit 97021a58b2d41f64b55e4dcb8257dd859817cd95 +Author: Fedaya +Date: Sun Dec 3 08:41:27 2023 +0100 + + Part 3 completed + +commit fbf1c66a3968f0f300cbb6d1895e71c515278a9e +Author: Fedaya +Date: Sat Dec 2 12:45:07 2023 +0100 + + Nouveau Repository + + Je perd l'historique, mais ne stocke plus les fichiers input.txt + entre autre choses + +commit 3e06d85867ceffb21d59c949bef8049e8b0670ef +Author: Fedaya +Date: Sat Dec 2 12:42:58 2023 +0100 + + Initial commit