A December of Algorithms 2019



A December of Algorithms 2019 was an open coding challenge organized by SVCE-ACM student chapter. For each day of the month they presented a small algorithmic programming problem. Solutions to all of the problems had to be submitted by 2020-01-10.


The holidays were approaching and I thought I’d need something to keep my little gray programming brain cells active. I was aware of Advent of Code, but I decided to do this challenge instead, because I considered it to be more approachable and doable, for sure. The algorithms that were chosen for the problems turned out to be fairly well-known and traditional, which, from a perspective of a student, was nice.

Some of the problems I had encountered whilst doing courses about data structures and algorithms, e.g. traveling salesman. Recursion and dynamic programming were already familiar to me. I can imagine that some of the challenges could have been challenging for a first year student who’d probably have done only the introductory programming and algorithms courses.

Why Haskell?

A couple of my friends were doing our university’s course about functional programming and bemoaning how hard it is to write Haskell. That prompted me to brush up my Haskell skills and show that it’s not that hard. I had done the course last year, so I had acquired the skills sufficient enough to overcome the challenge. Though, I admit that it certainly wasn’t the easiest way to do the challenge. It surely didn’t help that there were very few examples of how to solve i.e. graph problems in Haskell. Also, I tried to keep the dependencies to the minimum.

For the uninitiated, Wikipedia describes Haskell with following words:

Haskell is a statically typed, purely functional programming language with type inference and lazy evaluation.

What each of those fancy features means is best explained on the Haskell homepage. (Scroll down a bit to see the explanations with examples)

While working on the problems, I was regularly amazed by how expressive Haskell code can be. I think some of the best examples are 06 and 27. Ignoring comments and type annotations (which are optional, but I happen to prefer typing them out) the code is, is in my opinion, really concise. Of course there were problems (like 08) that would have been easier to solve in other languages like C++ or Python.


All in all I’m happy that the coding challenge didn’t take too big of a slice of my holidays and I got time to spend time with family and relax petting our cat. I think that I got better at approaching problems from a functional programming perspective and certainly learned a lot about Haskell while revising the stuff that was taught on our university’s FP course. I read quite a lot of Learn You a Haskell for Great Good and I think it is a good tutorial. The humour in the book is witty (although sometimes mean) and I really like the doodles illustrating the book.

Back to Posts