Post AcVz5kZdRnWUIKLtgW by Armavica@fosstodon.org
(DIR) More posts by Armavica@fosstodon.org
(DIR) Post #AcVz5kZdRnWUIKLtgW by Armavica@fosstodon.org
2023-12-05T21:17:46Z
0 likes, 0 repeats
I don't know why but I have always liked interval arithmetic. One way to solve today's part 2 was to map whole ranges at a time instead of individual numbers. A range is mapped to several new smaller ranges, depending on how it intersects with the next mapping.As you go through more and more mappings, you have to map more and more ranges, but that's still much faster than going through all numbers one by one.#AdventOfCode
(DIR) Post #AcVz5lZJkSrZNdD9pQ by drgeraint@glasgow.social
2023-12-05T23:43:11Z
0 likes, 0 repeats
@Armavica That looks like a complicated but interesting way of solving the problem.Could you give an example of how you mapped the ranges?I can see how one could be done efficiently, but I can't see how doing that for large ranges through many tables would simplify the problem much,
(DIR) Post #AcW23xnLcVeMaBbcBs by Armavica@fosstodon.org
2023-12-06T00:16:26Z
0 likes, 0 repeats
@drgeraint Sure! Does that help?
(DIR) Post #AcWKS9dL3RapQMbo6C by jeff@phpc.social
2023-12-06T03:42:31Z
0 likes, 0 repeats
@drgeraint @Armavica If you think in terms of DFS, each step in the sequence explores all possible destination ranges given a source range. It's usually only a few nodes (especially compared to iterating millions of ints).For instance, if an initial seed range overlaps multiple soil destinations, expand each of those, each of their fertilizer dests, and so on.The location node you expand with the lowest start is the answer to Part 2. Runs in ms