what a doozy. iterative solution from part 1 totally untenable. recursive solution a bit tricky, but still not fast enough for brute force. had to implement memoization cache for reasonable runtime.
Slow and inefficient but fast enough for a solve