TAAFT
Free mode
100% free
Freemium
Free Trial
Deals

Advent of Code 2022

badboy / adventofcode2022

My solutions to Advent of Code 2022, in SQL

2 0 Language: Shell Updated: 8mo ago

README

Advent of Code 2022

If all you have is data, everything looks like a SELECT.

My solutions to this year's Advent of Code, done in SQL, incomplete.

I blogged about it: SELECT solution FROM aoc WHERE year = 2022.

Requirements

My own rules

  • Solve it in SQL.
  • Only the SQL the system provides. How far can I take this?
    • It was easier on BigQuery with its large base of functionality, including string procesing, arrays, structs, ...
    • On SQLite initially I tried to avoid any custom functionality, I later relaxed this rule: SQLean is okay occasionally.
    • Once (so far) I used Python to preprocess the data. SQL is just really not good at text processing.
  • Getting the solution once is good enough.
    • The code can be ugly, messy and inefficient.
  • I don't write tests.
    • I do test. Just manually against the test input.
  • No persistent data.
    • It's all in-memory tables, CTEs, temporary views and a bunch of SELECT.
  • Learn some arcane SQL features.
    • Did you know SQL can recurse and select over windows? I do now!

These are my rules. I break them when I feel like it.

Run it

(Nearly) Every day should be runnable by:

sqlite3 < aoc-01.sql
0 AIs selected
Clear selection
#
Name
Task