| From: | Bernice Southey <bernice(dot)southey(at)gmail(dot)com> |
|---|---|
| To: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
| Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Advent of Code Day 8 |
| Date: | 2025-12-16 16:19:21 |
| Message-ID: | CAEDh4nyVW-Q_-F2S8m5o+uVh53ea6FCSLXYJEqBu_8bRZy5YYg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Greg Sabino Mullane <htamfids(at)gmail(dot)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 a long 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Igor Korot | 2025-12-17 03:04:21 | PQexecPrepared() question |
| Previous Message | Greg Sabino Mullane | 2025-12-16 14:25:36 | Re: Advent of Code Day 8 |