Bits of Code - Pieces of Writing

Advent Of Code makes me a better programmer

Advent Of Code makes me a better programmer

Advent Of Code is a yearly event offered by Eric Wastl: every day before Christmas, you can unlock a daily code challenge and crack it with the programming language of your choice.

It's super funny, with a pleasant Xmas/elve/reindeer... background and a soft difficulty curve (anyone with some programming experience can take the first challenges).

This year was my second participation. For the first time I was able to go through all the 25 challenges (it took me a bit more than 25 days) and the only language I used was Elixir.

I will now share with you my Advent Of code takeaways.

1 - You're not an impostor ๐Ÿฅธ

Advent Of code is for anyone willing to improve their programming skills.

It doesn't matter if you are:

  • a competitive golf programmer used to crack challenges in less than 5 minutes to rank among the first ๐Ÿคฏ
  • a student or just some folk learning programming
  • a seasoned programmer willing to crank up his skills ( ๐Ÿ‘ˆ I'm here )
  • a seasoned programmer learning a new language (I might do next season's AOC in Rust)
Cranking up my typing skills

What relieved me the most was how welcoming and helpful the AOC community is. A new Reddit thread is opened every day and people are encouraged to share their solutions or ask for help.

2 - CS101 ... again ๐Ÿ‘จโ€๐ŸŽ“

If like me you graduated computer science quite a while ago, AOC might be the perfect occasion to refresh your academic knowledge.

Advent of Code will make you think about:

  • Algorithmic complexity, also known as "WTF why is my code running for 30 minutes and not yielding any result ?!?"
  • Data structures. Some challenges are tough without proper data modeling. So I suggest you know the ins and outs of basic data structures (chained lists, trees, and graphs) and related algorithms (depth-first vs breadth-first tree traversal)
  • Formal Grammar will help you with some challenge
  • Dynamic programming also saved me an evening of hacking.
infinite loop
Courtesy of Grady

3 - Coding Kata ๐Ÿฅ‹

We are no machines and we are not required to know anything by heart: so much knowledge is reachable online, within a few seconds.

Still, knowing a few will help.

AOC helped me to muscle my memory, and I'm now able to code most challenges in a single streak without reaching the documentation or copy-pasting from previous code. During this event, I reinforced my knowledge of some of the most important Elixir APIs (Enum, Stream, String, Regex).

Cobra Kai
Code Editor is your Dojo

By not abusing alt-tab and staying focused in your code editor you'll be able to reach what most athletes know as flow state: this mental state in which you feel the most enjoyed and productive.

Like athletes, everyday practice will give you reflex, confidence, and improve your judgment.

4 - And a few Elixir lessons ๐Ÿงช

Reddit hosts the biggest AOC community, but you can also look after smaller AOC sub-communities. I learned much from ad-hoc threads created on Elixir Forum.

Here are a few things I learned, mostly from reading at other's solutions:

  • Elixir comprehensions are powerful. They let you iterate, combine, filter and reduce in few line of codes (I recommend you this article)
  • Prepending is not appending - Elixir lists are not arrays. Those assumptions sound trivial but helped me make a 60 seconds program run within a few milliseconds. Elixir is immutable and as such if you want to append a single item to a list, Elixir will create a whole new copy of the list (Elixir can't modify the last item to point at your new item - immutable we said ;-). On the opposite, prepending to a list will only create a new item that will point to the previous untouched list. That's why Elixir gives us a powerful prepend operator prepended_list = [item | list]
  • Elixir most common APIs hide a few jewels that I never used in 4 years of Elixir Programming. With AOC I discovered Enum.chunk_every, Enum.chunk_while, or Stream.unfold
  • You have all Erlang magic at hand. I solved some of the challenges by using raw Erlang APIs such as ets, digraph, or the fairly new atomics module.
  • Immutability brings safety. Some challenges were tricky to code in some other languages because if you didn't take care of doing deep copies of your data structure you ran into an inconsistent state. In Elixir, there is no such thing as shared mutable state, so deep copy comes for free ๐Ÿ˜Ž
  • Immutability is slower. The cost of safety is that any write operation in Elixir will be slower than in any other languages with mutable data structures. ets or atomics Erlang APIs can sometimes be handy.

Final words

If you didn't know Advent Of Code before or just never tried, I hope this post will convince you to give a shot at it. AOC is not timebound and you can follow any event whenever you want at your own pace.

Oh, I forgot to mention that AOC is also a bit addictive and I may have started over from year 2015 ๐Ÿ™Š ๐Ÿ˜ ๐ŸŽ„


Christian Blavier

Currently VP Technology at PhenixDigital, I'm a passionate Elixir, Ruby & JS programmer. Former founder and CTO at,

View Comments
Previous Post

On Elixir Metaprogramming