Advent of Code 2023

It's a variation on the same theme. @cache makes some choices: it uses a thread safe cache, which means you don't need to worry about the sendability concerns I mention, but at the same time, you pay a price if you don't need thread safety. You might also want to use a function body macro in Swift instead of a higher-order function, as my approach requires that you name your function _possibilities but then you call the memoized possibilities function.

1 Like