# Advent of Code 2021 - all solutions

**URL:** <https://erlangforums.com/t/advent-of-code-2021-all-solutions/873>\
**Category:** Coding Challenges\
**Tags:** advent-of-code\
**Created:** [December 27, 2021, 9:24am UTC](https://erlangforums.com/t/advent-of-code-2021-all-solutions/873 "2021-12-27T09:24:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jesperes](https://erlangforums.com/user_avatar/erlangforums.com/jesperes/32/1941_2.png) [@jesperes](https://erlangforums.com/u/jesperes)\
**Post date:** [December 27, 2021, 9:24am UTC](https://erlangforums.com/t/advent-of-code-2021-all-solutions/873/1 "2021-12-27T09:24:59Z")

</div>

So I finished all the 2021 solutions in Erlang with a total runtime of \< 10s which I am very happy with:

```erlang
Year Day Name Time (msecs)
------ ----- ----------------------- --------------
2021 24 Arithmetic Logic Unit 0.338
2021 10 Syntax Scoring 0.717
2021 2 Dive! 0.773
2021 1 Sonar Sweep 0.849
2021 6 Lanternfish 0.963
2021 13 Transparent Origami 2.112
2021 3 Binary Diagnostics 2.619
2021 14 Extended Polymerization 4.008
2021 16 Packet Decoder 4.83
2021 8 Seven Segment Stretch 7.495
2021 9 Smoke Basin 13.564
2021 4 Giant Squid 23.715
2021 22 Reactor Reboot 40.28
2021 11 Dumbo Octopus 58.305
2021 7 The Treachery of Whales 91.935
2021 21 Dirac Dice 140.429
2021 17 Trick Shot 160.075
2021 12 Passage Pathing 274.693
2021 5 Hydrothermal Venture 321.489
2021 18 Snailfish 409.204
2021 15 Chiton 732.866
2021 25 Sea Cucumber 781.054
2021 19 Beacon Scanner 1934.517
2021 23 Amphipod 2031.776
2021 20 Trench Map 2361.754
               Total time 9.43458 secs

```

All solutions can be found here: [GitHub - jesperes/aoc\_erlang: Advent of Code Solutions in Erlang](https://github.com/jesperes/aoc_erlang).

---

<div class="post-metadata">

**Author:** ![AstonJ](https://erlangforums.com/user_avatar/erlangforums.com/astonj/32/9_2.png) [@AstonJ](https://erlangforums.com/u/AstonJ)\
**Post date:** [December 28, 2021, 3:50am UTC](https://erlangforums.com/t/advent-of-code-2021-all-solutions/873/2 "2021-12-28T03:50:30Z")

</div>

Awesome stuff Jesper, I wonder if anyone else completed all of them? :003:

I guess @bjorng did? :lol:

---

<div class="post-metadata">

**Author:** ![jesperes](https://erlangforums.com/user_avatar/erlangforums.com/jesperes/32/1941_2.png) [@jesperes](https://erlangforums.com/u/jesperes)\
**Post date:** [December 28, 2021, 11:17am UTC](https://erlangforums.com/t/advent-of-code-2021-all-solutions/873/3 "2021-12-28T11:17:15Z")

</div>

I’ve done all the previous years in Erlang, but this is the first year that I managed to break the 10s barrier.

---

<div class="post-metadata">

**Author:** ![VyacheslavLevytskyy](https://erlangforums.com/user_avatar/erlangforums.com/vyacheslavlevytskyy/32/905_2.png) [@VyacheslavLevytskyy](https://erlangforums.com/u/VyacheslavLevytskyy)\
**Post date:** [December 28, 2021, 9:51pm UTC](https://erlangforums.com/t/advent-of-code-2021-all-solutions/873/4 "2021-12-28T21:51:25Z")

</div>

I participated for the first time, and sometime it was painful - but no doubt it’s real fun in general. Thank you @bjorng for letting know about AoC in the mailing list and thank you @jesperes for the benchmark and additional motivation to revisit some of 25 days without haste 😉

---

<div class="post-metadata">

**Author:** ![wojtek](https://erlangforums.com/letter_avatar_proxy/v4/letter/w/c77e96/32.png) [@wojtek](https://erlangforums.com/u/wojtek)\
**Post date:** [January 1, 2022, 12:14pm UTC](https://erlangforums.com/t/advent-of-code-2021-all-solutions/873/5 "2022-01-01T12:14:25Z")

</div>

It was my first time too. I like the idea very much and I had great time working in AoC, though often it was tough time as well 🙂 You can find my Erlang solutions to all problems at [GitHub - wojteksurowka/aoc2021](https://github.com/wojteksurowka/aoc2021)

---

<div class="post-metadata">

**Author:** ![VyacheslavLevytskyy](https://erlangforums.com/user_avatar/erlangforums.com/vyacheslavlevytskyy/32/905_2.png) [@VyacheslavLevytskyy](https://erlangforums.com/u/VyacheslavLevytskyy)\
**Post date:** [October 10, 2022, 12:40pm UTC](https://erlangforums.com/t/advent-of-code-2021-all-solutions/873/6 "2022-10-10T12:40:28Z")

</div>

It was such a fun to revisit AoC2021 with C++, improving at last day 23 (hooray) and compare it to Erlang. More often than not I tried to repeat C++ solutions by the corresponding Erlang code, so funnier it was to see how eventual implementation differs and a cunning scheme designed for one language doesn’t work for another. Final timings say us nothing as always 🙂 but I share them anyway.

```erlang
$ ./aoc2021
25 C++ days:
Time elapsed:
    day 1: 1.4ms
    day 2: 0.9ms
    day 3: 1.1ms
    day 4: 7.1ms
    day 5: 5.5ms
    day 6: 0.1ms
    day 7: 3.4ms
    day 8: 9.7ms
    day 9: 12.2ms
    day 10: 0.3ms
    day 11: 63.5ms
    day 12: 141.5ms
    day 13: 3.7ms
    day 14: 3.4ms
    day 15: 1732.7ms
    day 16: 0.5ms
    day 17: 2.7ms
    day 18: 122.1ms
    day 19: 75.5ms
    day 20: 130.2ms
    day 21: 89.6ms
    day 22: 1061.7ms
    day 23: 5845.2ms
    day 24: 0.1ms
    day 25: 173.7ms
Average: 379.5ms

```

```erlang
2> aoc_tc:run().
25 Erlang days:
    day 1: 0.702ms
    day 2: 0.531ms
    day 3: 0.952ms
    day 4: 12.308ms
    day 5: 250.932ms
    day 6: 0.379ms
    day 7: 4.208ms
    day 8: 1.595ms
    day 9: 4.938ms
    day 10: 0.422ms
    day 11: 29.911ms
    day 12: 35.826ms
    day 13: 2.442ms
    day 14: 3.953ms
    day 15: 1353.175ms
    day 16: 0.61ms
    day 17: 1.511ms
    day 18: 74.62ms
    day 19: 34.571ms
    day 20: 1743.531ms
    day 21: 86.588ms
    day 22: 1288.99ms
    day 23: 2200.571ms
    day 24: 0.006ms
    day 25: 2209.278ms
Total: 9342.55ms
Average: 373.702ms

```

Solutions are here: [VyacheslavLevytskyy (Vyacheslav Levytskyy) · GitHub](https://github.com/VyacheslavLevytskyy)
