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
- AoC 2020 in Nim, one liner-y Python, Racket (this repo)
- AoC 2021 in Python, Racket
- AoC 2022 in Python, Clojure
- AoC 2023 in Clojure
- AoC 2024 in Clojure (Clerk notebooks)
Task | Nim | Python | Racket | Comments (for Nim solutions) |
---|---|---|---|---|
Day 1: Report Repair | day01.nim | day01.py | day01.rkt | Small check elif s[i] + s[j] < 2020: makes the whole program ~4x faster. |
Day 2: Password Philosophy | day02.nim | day02.py | day02.rkt | scanf useful as always. |
Day 3: Toboggan Trajectory | day03.nim | day03.py | day03.rkt | Keeping it below 20 lines :) |
Day 4: Passport Processing | day04.nim | day04.py | day04.rkt | Had a nasty early morning bug with if not v.len == 9 . Argh. |
Day 5: Binary Boarding | day05.nim | day05.py | day05.rkt | Traversing a sorted list is more efficient than looking for every number in unsorted one. |
Day 6: Custom Customs | day06.nim | day06.py | day06.rkt | Classic AoC-use-sets tasks. |
Day 7: Handy Haversacks | day07.nim | day07.py | day07.rkt | Babushka bag = Bagushka. |
Day 8: Handheld Halting | day08.nim | day08.py | day08.rkt | Faster than it looks. |
Day 9: Encoding Error | day09.nim | day09.py | day09.rkt | Sliding slice sum. |
Day 10: Adapter Array | day10.nim | day10.py | day10.rkt | CountTable to the rescue. |
Day 11: Seating System | day11.nim | The ugliest and the slowest solution so far. | ||
Day 12: Rain Risk | day12.nim | day12.py | day12.rkt | Using complex numbers is soooo last Tuesday. No Complex this time. |
Day 13: Shuttle Search | day13.nim | day13.py | day13.rkt | Yeah yeah, CRT, but it took me way too long to implement it correctly. |
Day 14: Docking Data | day14.nim | Good luck trying to understand what's going on. | ||
Day 15: Rambunctious Recitation | day15.nim | Boring. | ||
Day 16: Ticket Translation | day16.nim | Naming is hard. | ||
Day 17: Conway Cubes | day17.nim | Nobody notices your 9 nested for-loops if you hide them in a template. | ||
Day 18: Operation Order | day18.nim | Template and streams make this one really elegant. | ||
Day 19: Monster Messages | day19.nim | My first experience with npeg . |
||
Day 20: Jurassic Jigsaw | ||||
Day 21: Allergen Assessment | day21.nim | Day 16, part 2 vibes. | ||
Day 22: Crab Combat | day22.nim | Deque Deck for Crab Combat. | ||
Day 23: Crab Cups | day23.nim | No Linked List for Crab Cups: 10x faster and lighter (less memory usage). | ||
Day 24: Lobby Layout | day24.nim | Read redblobgames if you haven't already. | ||
Day 25: Combo Breaker | day25.nim |
- Nim version 1.5.1 (devel)
- compiled with
-d:danger --gc:arc
- CPU: AMD Ryzen 3700x @ 3.6 GHz (Linux 5.4)
The reported results are the average of 20 runs.
01 0.72 ms
02 0.82 ms
03 0.63 ms
04 1.23 ms
05 0.80 ms
06 0.96 ms
07 1.89 ms
08 1.06 ms
09 1.01 ms
10 0.72 ms
11 26.66 ms
12 0.93 ms
13 0.63 ms
14 11.57 ms
15 583.13 ms
16 4.62 ms
17 64.36 ms
18 1.48 ms
19 17.52 ms
20 12.16 ms
21 1.86 ms
22 1.06 ms
23 208.55 ms
24 16.32 ms
25 5.42 ms
--------------
966 ms