sebastiano.tronto.net

Source files and build scripts for my personal website
git clone https://git.tronto.net/sebastiano.tronto.net
Download | Log | Files | Refs | README

advent-of-code.md (3415B)


      1 # Advent of Code
      2 
      3 The [Advent of Code](https://adventofcode.com) is an online programming
      4 contest that takes place every year in December. It works like an
      5 [advent calendar](https://en.wikipedia.org/wiki/Advent_calendar), except
      6 each day instead of a piece of chocolate or a sweet you get a new problem
      7 to solve.
      8 
      9 I have taken part in this contest for the first time this year, after
     10 an email from a colleague that mentioned prizes for the winner of our
     11 private leaderboard. Even without any prize, if it is a challenge
     12 then I must accept it!
     13 
     14 *Warning: if you are still trying to complete the problems, you may find
     15 minor spoilers ahead, but nothing game-breaking.*
     16 
     17 ## Choosing my weapons
     18 
     19 As I was initially not planning on taking part in the challenge, I did
     20 not have much time to decide which language or tools to use. I opted for
     21 solving the problems in C, because it is the language I worked with the
     22 most recently, but in hindsight it would have been more convenient to
     23 refresh my Python or C++ skills.
     24 
     25 In the end using a more limited language did not make a big difference: the
     26 easy problems were still easy, some of the hard ones became a bit slower
     27 to type out. I also had some fun implementing some basic data structures,
     28 for example [heaps](https://en.wikipedia.org/wiki/Heap_(data_structure))
     29 for [day 17](https://adventofcode.com/2023/day/17).
     30 
     31 ## The fun
     32 
     33 Overall, I really enjoyed solving these problems! I liked the diverse
     34 set of techniques that were needed: graph algorithms, dynamic programming,
     35 computational geometry... a very nice selection of brain teasers!
     36 
     37 I also liked the fact that the difficulty increased *on average*, but
     38 sometimes a hard problem was be followed by an easier one. This way,
     39 even if I found a problem particularly hard, I could still hope that
     40 the next one would be quicker to solve.
     41 
     42 I also liked that other people, including friends, colleagues and my
     43 girlfriend, were taking on the challenge at the same time. I enjoyed
     44 explaining my solution or asking my friends to explain theirs. By the
     45 way, my friend Jared has some in-depth explanation of his solutions
     46 in his [blog](https://guissmo.com/blog/) - check it out!
     47 
     48 ## The ugly
     49 
     50 There were a couple of problems that I disliked, and all of them for
     51 the same reason: the problem was not solvable without taking advantage
     52 of specific properties of the input data that were not made explicit in
     53 the problem's statement.
     54 
     55 As a Mathematician, I am never going to randomly assume that a generic
     56 graph has a specific structure, or that just throwing the
     57 [lcm](https://en.wikipedia.org/wiki/Least_common_multiple) into my
     58 algorithm would make it work. So I was scratching my head for hours trying
     59 to solve a general problem that was very likely unsolvable, when I only
     60 had to solve a special case.
     61 
     62 However, as a Reddit user pointed out, the input data *is* part of the
     63 problem statement. Analyzing it to figure out what algorithm may work
     64 is a skill. I guess I learnt something from this.
     65 
     66 ## Solutions
     67 
     68 If you are interested, you can find all my solutions on
     69 [my git page](https://git.tronto.net/aoc/) and on
     70 [Github](https://github.com/sebastianotronto/aoc). They are written in
     71 [C99](https://en.wikipedia.org/wiki/C99) without any external dependency
     72 other than the C standard library.
     73 
     74 Apart from the harder problems, I have not commented my solutions much,
     75 but you can send me an email if you want some explanation!