I am attempting to solve Advent of Code Day 21, specifically part 2 of the problem, which just asks for the same solution on the 18th iteration.
My problem is that both the grouping method used, and the method where I manually construct the grid index by index are both extremely slow. They start slowing down massively at around iteration 15, and they usually get terminated after iteration 17 is reached (oom, maybe?)
I’d like to know how to improve these functions. my code is at https://github.com/razetime/aoc/blob/main/17/21.lil.