{"id":18829468,"url":"https://github.com/michaeladler/aoc-2021","last_synced_at":"2025-09-07T20:50:16.220Z","repository":{"id":145747397,"uuid":"474041119","full_name":"michaeladler/aoc-2021","owner":"michaeladler","description":"My solutions for the Advent of Code 2021","archived":false,"fork":false,"pushed_at":"2022-03-25T16:16:43.000Z","size":185,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-04T08:13:19.528Z","etag":null,"topics":["advent-of-code","advent-of-code-2021","aoc","aoc2021","cpp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaeladler.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-25T14:25:29.000Z","updated_at":"2022-05-03T14:32:04.000Z","dependencies_parsed_at":"2023-03-29T03:18:00.242Z","dependency_job_id":null,"html_url":"https://github.com/michaeladler/aoc-2021","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/michaeladler/aoc-2021","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeladler%2Faoc-2021","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeladler%2Faoc-2021/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeladler%2Faoc-2021/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeladler%2Faoc-2021/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaeladler","download_url":"https://codeload.github.com/michaeladler/aoc-2021/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeladler%2Faoc-2021/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274095187,"owners_count":25221432,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["advent-of-code","advent-of-code-2021","aoc","aoc2021","cpp"],"created_at":"2024-11-08T01:44:55.609Z","updated_at":"2025-09-07T20:50:16.196Z","avatar_url":"https://github.com/michaeladler.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/michaeladler/aoc-2021/actions/workflows/ci.yml/badge.svg)](https://github.com/michaeladler/aoc-2021/actions/workflows/ci.yml)\n\n# aoc-2021\n\nMy third [Advent of Code](https://adventofcode.com/).\nThis time using C++, the objective is to have a total runtime of less than 60 seconds.\n\n## Benchmarks\n\n* Intel(R) Core(TM) i7-5600U:  13.9 sec\n* Intel(R) Core(TM) i7-7820HQ: 13.5 sec\n* Intel(R) Core(TM) i7-11850H: 7.7 sec\n\n## Lessons Learned\n\n### Meson\n\nMeson and NixOS do not work well together: [meson strips `RPATH`](https://web.archive.org/web/20211215093316/https://bleepcoder.com/meson/117487924/rpath-doesn-t-get-set-with-find-library-foo-dirs-path-to-lib)\n\nWorkaround: `LDFLAGS=\"-Wl,-rpath=${fmtlog}/lib\"`\n\n### Polymorphic Allocators\n\n* [OOP2021-pmr-STL-fuer-Embedded-Applications-en.pdf](https://web.archive.org/web/20211214103145/https://www.rkaiser.de/wp-content/uploads/2021/02/OOP2021-pmr-STL-fuer-Embedded-Applications-en.pdf)\n* https://www.cppstories.com/2020/08/pmr-dbg.html/\n\n### Delete while Iterate\n\nDeleting while iterating a hash map (or set) is not possible in Java, but in C++ it is:\n\n```c\nit = co2_numbers.erase(it);\n```\n\n## Puzzles\n\nHardest puzzles:\n\n1. Day 19: Beacon Scanner\n2. Day 21: Dirac Dice\n3. Day 22: Reactor Reboot\n\n### Day 2\n\n* `std::span` is very useful\n\n### Day 6\n\n* took me quite a while to come up with *bins* and avoid the out-of-memory problem (for me the hardest problem in days 1-11)\n* `std::accumulate`: the last argument type determines the type used for the summation! use `(uint64_t)0` to prevent integer overflow for large positive numbers.\n\n### Day 9\n\n* `std::tuple` is not hashable by default, see https://stackoverflow.com/a/15161034 for a solution\n\n### Day 12\n\n* Used the generic backtracking recipe from [Skiena](https://www3.cs.stonybrook.edu/~skiena/392/programs/). DFS would have been more efficient though.\n\n### Day 16\n\n* Lots of bit fiddling, but quite fun\n* Should get rid of `stringstream`, possible speed up\n\n### Day 18\n\n* Ugly solution using string instead of a tree representation, but still reasonably fast\n* *Lots* of corner cases and bugs/off-by-one errors (=\u003e *many* tests)\n* Did not enjoy this puzzle\n\n### Day 21\n\n* Lanternfish revisited\n* To toggle between 0 and 1 in the loop: `active_idx = 1 - active_idx`.\n  This is the same as `active_idx = (active_idx + 1) % 2`.\n* Part 2 was tricky\n\n### Day 22\n\n* Many corner-cases to consider\n* Quite difficult\n\n### Day 23\n\n* Rather easy using backtracking approach although much slower than A*\n* Does not produce correct result when compiling with gcc! You *must* use clang. Weird.\n\n### Day 24\n\n* My favorite puzzle! Very interesting.\n* Used a Python script to convert ALU to CPP code and then simplified the code until I found a solution\n    =\u003e Does not work with other inputs than mine\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeladler%2Faoc-2021","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaeladler%2Faoc-2021","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeladler%2Faoc-2021/lists"}