Jan van den Berg

Advent of Code

Advent of Code is a yearly programming contest created by Eric Wastl and it is currently being held at adventofcode.com. That means that this site spawns two daily programming challenges -- until Christmas -- to see who can solve them the fastest. But it is not just about being fast, Advent of Code is also a great way to improve your programming skills with daily puzzles or learn a new language. Because everyone gets the same daily puzzles it is also a great way to share and discuss results, and above all, learn.

Though I knew of Advent of Code, I hadn't participated before, but it seems two days, and four puzzles later, I am sort of in. Or at least, after only two days I am already fascinated by what I have seen, so I thought I'd share!

Fascinating findings

https://www.youtube.com/watch?v=Hgv6d6rrQxo

Notable entries

So it's not all about speed, it's also about trying new things. Here are some other unexpected examples.

https://streamable.com/pxaze

Personal learnings so far

So apart from these fascinating findings, I also got involved myself. I think because I solved the very first challenge with a simple AWK one-liner. But solving the followup challenge seemed trickier in AWK, though people seem to have done so (of course).

Being completely new to Python, and seeing how popular it is, I decided to give it a go, and I must say I think I understand a bit better now why and how Python is so popular. Yes, it is well known that it forces deliberately clean codebut it also provides ways for incredibly succinct code. And so far I have learned about map(), collections.counter, zip(), and cycle() Very handy, built-in functions and datatypes that I was unaware of, but which are incredibly powerful.

Some people tend to disagree (probably very few), as I found this comment on StackOverflow when researching the Counter dict.

I don't think that's fair, because in a sense every higher level programming language is an abstraction of differently expressed machine code. So unless you're typing in machine code directly you are also using general purpose tools, and how narrow or general something is, who's to say? And as long as it helps people do things faster -- programming languages are tools after all -- I'm all for it. Just let the computer worry about the zeros and ones.

I was very surprised and pleased with the mentioned Python functions. For example, I brute-forced a solution in Bash which took probably more than 10 minutes to run, but ran in 0.07 seconds in only a couple of lines of Python. So, of course, the knowledge of the right functions and data structures once again proved to be the difference between 100 lines or 10, which reminded me of this quote of Linus Torvalds:

So that's it and if you want to learn something new, go give it a try!

advent-of-code, awk, elixir, github, haskell, programming, python, tech

⬅ Previous post
The Good, the Bad and the Ugly of Red Dead Redemption 2

Next post ➡
Can we replace paper?