{"id":15393901,"url":"https://github.com/mitchellh/advent-2021-sql","last_synced_at":"2025-04-06T12:12:19.382Z","repository":{"id":43167137,"uuid":"434340281","full_name":"mitchellh/advent-2021-sql","owner":"mitchellh","description":"Advent of Code 2021 using SQL (PostgreSQL-flavored)","archived":false,"fork":false,"pushed_at":"2021-12-07T19:59:10.000Z","size":62,"stargazers_count":442,"open_issues_count":2,"forks_count":9,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-04-01T16:06:05.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitchellh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-02T18:59:26.000Z","updated_at":"2025-01-13T14:10:40.000Z","dependencies_parsed_at":"2022-09-13T12:23:57.148Z","dependency_job_id":null,"html_url":"https://github.com/mitchellh/advent-2021-sql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fadvent-2021-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fadvent-2021-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fadvent-2021-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fadvent-2021-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitchellh","download_url":"https://codeload.github.com/mitchellh/advent-2021-sql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478325,"owners_count":20945266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T15:20:44.890Z","updated_at":"2025-04-06T12:12:19.362Z","avatar_url":"https://github.com/mitchellh.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Advent of Code 2021 with PostgreSQL\n\nThis repository contains my solutions for [Advent of Code 2021](https://adventofcode.com/2021)\nusing PostgreSQL-specific SQL.\n\nI'm not an expert at SQL (or PostgreSQL) by any means. One of the reasons I\ndecided to use SQL was to regain some proficiency while also learning some\nnew concepts. I expect that many of my solutions are suboptimal and there\nare likely much _better_ ways (by various definitions) to reach the same\nanswer. I'd love to hear about those (make an issue) but I won't be merging\nany changes since this represents _my_ approach.\n\n**I may not finish!** December is a busy time, I'm doing these as I can,\nbut I'm not making any commitment to finishing. If I don't finish, I'll\nhopefully retroactively solve the problems, but no promises. 😜\n\n## Goals\n\nI had a set of goals with each problem:\n\n* Ingest input directly without any modification.\n\n* Arrive at the solution using a single SQL statement. No `UPDATE` queries\n  to transform the data prior to the statement. Huge CTEs to simulate temporary\n  tables is totally fine.\n\n* No custom functions (no plpgsql). It's too easy to think _iteratively_ with \n  custom functions and one of my goals is to think _relationally_. \n\n* Timebox to 30 minutes per problem for both parts.\n\nIf I was creeping up towards my timebox, I broke some of these rules in\nthe interest of getting to an answer. However, I did my best to stick with\nthe rules as well as possible. For example, in week 1, I achieved all of the\nabove except I had to drop into plpgsql for 1 part of 1 problem (on day 3).\n\n## Explanations\n\nI uploaded video explanations for each day I completed to YouTube:\n\nhttps://www.youtube.com/watch?v=aIVBYKk5adk\u0026list=PL4z1WbdlT5GJqdGnuvoqw4dOdB2etJ6sd\n\n## Usage\n\nBring up the PostgreSQL database with `docker compose up -d`.\n\nDrop into a PostgreSQL console with `make`.\n\nRun the day: `\\i day01/answer.sql;`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Fadvent-2021-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchellh%2Fadvent-2021-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Fadvent-2021-sql/lists"}