AdventOfCode2021
My solutions for AoC 2021
Install / Use
/learn @narimiran/AdventOfCode2021README
Advent of Code 2021
All my Advent of Code repos:
- AoC 2015 in Nim, Python
- AoC 2016 in Python, Clojure (+ visualizations)
- AoC 2017 in Nim, OCaml, Python
- AoC 2018 in Nim, Python, Racket
- AoC 2019 in OCaml, Python, Clojure
- AoC 2020 in Nim, one liner-y Python, Racket
- AoC 2021 in Python, Racket (this repo)
- AoC 2022 in Python, Clojure
- AoC 2023 in Clojure
- AoC 2024 in Clojure (Clerk notebooks), Python, Elixir
- AoC 2025 in Clojure (Clerk notebooks)
This year it is back to roots - Python!
I'll probably add solutions in other languages on some later date.
EDIT, November 2022: And I did - I've solved initial days in Racket too.
EDIT, November 2025: Days 19, 22, 23 were solved in Clojure.
Solutions
Task | Python Solution | Racket Solution | Comment for Python solution
--- | --- | --- | ---
Day 00: Helper file | aoc.py | aoc.rkt | Utilities to use for solving the tasks.
Day 01: Sonar Sweep | day01.py | day01.rkt | (a + b + c) < (b + c + d) --> a < d
Day 02: Dive! | day02.py | day02.rkt | "Up, up, down, down, left, right, left, right..."
Day 03: Binary Diagnostic | day03.py | day03.rkt | from collections import Counter
Day 04: Giant Squid | day04.py | day04.rkt | Set operations (<=, -) to the rescue.
Day 05: Hydrothermal Venture | day05.py | day05.rkt | TIL defaultdict is faster than Counter.
Day 06: Lanternfish | day06.py | day06.rkt | Recursion with memoization.
Day 07: The Treachery of Whales | day07.py | day07.rkt | Mean mean!
Day 08: Seven Segment Search | day08.py | day08.rkt | Using Python 3.10 and pattern matching.
Day 09: Smoke Basin | day09.py | day09.rkt | Recursive DFS.
Day 10: Syntax Scoring | day10.py | day10.rkt | dict(zip(...)) for easier typing
Day 11: Dumbo Octopus | day11.py | day11.rkt | Iterative DFS.
Day 12: Passage Pathing | day12.py | day12.rkt | Recursive DFS generator with yield from.
Day 13: Transparent Origami | day13.py | day13.rkt | Fold. Not fold.
Day 14: Extended Polymerization | day14.py | | Counter to the rescue.
Day 15: Chiton | day15.py | | Dijkstra.
Day 16: Packet Decoder | day16.py | | iter for some elegant stream implementation.
Day 17: Trick Shot | day17.py | | Analytical + brute force.
Day 18: Snailfish | day18.py | | My first ever eval in 7 instances of AoC.
Day 19: Beacon Scanner | day19.py | day19.clj |
Day 20: Trench Map | day20.py | | I had 9-neighbours helper ready.
Day 21: Dirac Dice | day21.py | | Lanternfish says hi!
Day 22: Reactor Reboot | day22.py | day22.clj |
Day 23: Amphipod | day23.py | day23.clj |
Day 24: Arithmetic Logic Unit | day24.py | |
Day 25: Sea Cucumber | day25.py | |
