Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVXmO-004tgw-1k for pgsql-general@arkaria.postgresql.org; Tue, 16 Dec 2025 16:20:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVXmM-007bU3-14 for pgsql-general@arkaria.postgresql.org; Tue, 16 Dec 2025 16:20:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVXmL-007bTq-2x for pgsql-general@lists.postgresql.org; Tue, 16 Dec 2025 16:20:02 +0000 Received: from mail-yx1-xb131.google.com ([2607:f8b0:4864:20::b131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vVXmK-0014h8-0M for pgsql-general@lists.postgresql.org; Tue, 16 Dec 2025 16:20:02 +0000 Received: by mail-yx1-xb131.google.com with SMTP id 956f58d0204a3-640e065991dso3889995d50.3 for ; Tue, 16 Dec 2025 08:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765901997; x=1766506797; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EDEWhOynKZImHdejLPZUHSLNA8s9T3QMCy1+2Emp9u8=; b=fCfSdlprFV7WgJxzXB00AW/zcm+IVmrh1RpfE/QUPqEazcJpu00P1kO4NJFzwEuVm/ OgNTrVu0WVO5XxiiurSIMY78TJdXJrbHj+PRhZGQrQCn3CPI5FwjxJ3jqMhldFsJ+ymV hya3Bdz4YAGvIrQyGjFRF1QVeMWHdfmDmkvqCW0LXV5sMGuykFBa7jFgsqEOQcVZwQAX 4LdbYkMsaMaZLxb18qz9nG9hRk7OKVDEtqT+lvb48jSlT75Gwgz3diKdMmZyjs7Y8eTP HGWJhBpCMW9y68TrJOu3TEJIQB9N17KpUnn4eVnIHVLg3FOt9WXvXj/U/nmSymdnR4n9 4heQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765901997; x=1766506797; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=EDEWhOynKZImHdejLPZUHSLNA8s9T3QMCy1+2Emp9u8=; b=v82uOYgPEgUACt19UkswoIWSZTh8VnZrjCZQnJni7dIHlO9z9KOoHBgqFEOXk8AODg 3akLCbK7DQL52IIukMBeD7ayxpAXxUIRazDe89HgAxhOq8nd1ulrXTina1n6k9ndR5eM sPLqM+XSI3d48K2Arg67XV1WXL9qRx0AV13qqqaKOqclFri1hlkF/E1O6ZuIKeeeEm0i rPBkVNneRaw5xX/aEidkkoSh2qIMoMh9nMl1f/CzYUzka1IPmgG47X3iv+OY355l0Bu5 yH/PntiWBLW2mOlUlTiQAjb1oX6g/E2cmigYdAznhqbpwCPC6vLbIdf3D2+TxiyJiLo6 xBXw== X-Gm-Message-State: AOJu0YwO9qI+WJ9ajxxh8Y4ayecgHI6wv/p0fWYx9+NsTDlh9Kz2vY8u Tp6laSbnuLu0InTHjSumegwWw4J+j3NWL51vLGY9clxOmHLnwajyrcFsX0/fCvclf9Qb+j+0qGO eq723B0bZ4AiAPiChfO06Ys9r/f/gh/nV10t8 X-Gm-Gg: AY/fxX5rrIRdHoYiSb0xQR2iNsYclIReopOez7nXbeAhZYTpOAw/VX4O5Ev2CmKfPBW q5QZSmHJZTSkKDHP6R+eIl7msz0+Fsyb0tQHvGVr4RD1v5uJXBJBHBDa24Kmu8GnXgX+Q4BaBj9 vyMQx2J1WNpgqm3Yb8Q+QDm2b75J2Q43EGsxMm66LcBLxE/xE3MXnz87uZLzEVTb+NMtOH/l3u4 1Au6Yftxnppd8oEIX0Dnr6ZVfNXD1q6tDUQb7swARbUTiPGaJI59pKplXl6/H++y/xoUGbKtlOE OCJdxO/kWILlRUgJqUBs X-Google-Smtp-Source: AGHT+IEuVzlnS3r4FsqrkvJy+ZZQySLn11geeIQIMEGrcxQ7JqRGximIBWJr1D7lUY5g2JWpTq1OD0ATi73MiTBmzsk= X-Received: by 2002:a05:690e:4106:b0:63f:c4f4:e1a3 with SMTP id 956f58d0204a3-645555bd713mr10914207d50.13.1765901997326; Tue, 16 Dec 2025 08:19:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bernice Southey Date: Tue, 16 Dec 2025 16:19:21 +0000 X-Gm-Features: AQt7F2q-E29KGN2rR8VgSFDVAdTNGK4EldcWsh1LJYcPTJL96UAme2XE0oQWfhg Message-ID: Subject: Re: Advent of Code Day 8 To: Greg Sabino Mullane Cc: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Greg Sabino Mullane 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, w= hich runs slow compared to other languages, but runs as a single SQL statem= ent 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.