Greg Sabino Mullane <htamfids@gmail.com> wrote:
> As I said, I'm trying to solve them in a single statement. Recursive CTEs, CASE, and creative use of JSON can get you
along way. Here's my day 7, which runs slow compared to other languages, but runs as a single SQL statement and no
plpgsql,and I think is a good solution:
This took some head scratching but is very clever. I see there are
plenty of tricks for working around the limitations of recursive CTEs.
If you do ever get to 10, I'd be very curious to see your answer. I
used a recursive CTE for part 1, but cheated by limiting the recursion
to a fixed big enough number. I've been struggling with branch
pruning. I'm also interested in how you solve 11, if you use a
recursive CTE trick for part 2. The no aggregates drove me to a for
loop.
I was planning to check out your blog for 2022 if I ever caught up on
old AoCs, but 10 years is a bit steep. Now I'm thinking if I should
just read it for the tricks, and skip the puzzling.