Re: Advent of Code Day 8 - Mailing list pgsql-general

From Bernice Southey
Subject Re: Advent of Code Day 8
Date
Msg-id CAEDh4nyVW-Q_-F2S8m5o+uVh53ea6FCSLXYJEqBu_8bRZy5YYg@mail.gmail.com
Whole thread Raw
In response to Re: Advent of Code Day 8  (Greg Sabino Mullane <htamfids@gmail.com>)
Responses Re: Advent of Code Day 8
List pgsql-general
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.



pgsql-general by date:

Previous
From: Greg Sabino Mullane
Date:
Subject: Re: Advent of Code Day 8
Next
From: Igor Korot
Date:
Subject: PQexecPrepared() question