Advent of Code 2023 wrap up

Reflections on participating in this seasonal coding challenge.

Advent of Code
R
Author

Ella Kaye

Published

December 30, 2023

This year I’ve been writing up my Advent of Code solutions, with explanations, on a dedicated site. This is a cross-post of my final entry of the year from there.

This was my first year taking Advent of Code seriously, attempting to complete puzzles on the day they were released.1 Well, I say “seriously” – actually, it was a lot of fun!

As of December 25th, I have 30 stars: 12 days with both parts2 of the puzzle complete, 6 days with just part 13. I’m happy with that.4

I stuck to my intention of solving most of the puzzles in base R, though taking a tidyverse approach when it struck me as the most appropriate, and making use of igraph and tidygraph when a graph structure was called for. I learnt a lot. I got more comfortable with base R, including learning how to use functions for working with regular expressions. I became familiar with new additions to the tidyverse, such as the separate_*() family of functions and consectutive_id(). Moreover, I met my goal of solving a puzzle in C, albeit only Part 1 of Day 1. I also picked up a little graph theory and learnt about algorithms such as Dijkstra’s, breadth-first search and depth-first search.

aochelpers

In the run-up to Advent of Code this year, I built this website for my solutions and explanations, along with a companion package, aochelpers. I wrote about those here. That work paid off. It feels neat to have a dedicated site and aochelpers really streamlined the process of developing my solutions and producing the posts.

As I expected, over the course of working on the challenges, I’ve written a few functions that I expect to use again in other iterations of Advent of Code, which I shall be adding to aochelpers in due course. I have other ideas to improve the package as well.

Use of LLMs

In my introduction post, I wrote that I wanted to see what I could learn from/about working with LLMs in these challenges. They were useful on Day 1 when I was working in C. Other than that, I mostly abandoned them.

On days when I knew how to solve the puzzles myself, having Copilot enabled in RStudio got in the way. I preferred writing out my own solution. On days when I thought Copilot might help, it instead introduced bugs into my code, e.g. on Day 11, when I wanted it to figure out the indices on which to split the matrix. It did at least give me some code I could alter, though in retrospect, by the time I’d figured out where Copilot was wrong and fixed it, it would have been quicker to do it myself from scratch.

Towards the end, I did try again with both ChatGPT and Copilot when I was stuck, for example on Day 24, Part 2, but both were unable to help, suggesting code that generated errors, which no amount to trying to get it to correct itself, or attempting to myself, could resolve.

One type of query I did find ChatGPT useful for was to have it remind me of fairly basic things that I had done or known before but forgotten, for example how to initiate an empty list of length \(n\)5, the equation of a straight line given a point and a gradient, or to check the ASCII value of a character. These are questions I would previously have googled, but these days, for these kinds of questions, getting the answer straight from ChatGPT is quicker and I trusted that it would be able to answer them correctly.

It struck me that many of the puzzles this year had convoluted instructions and examples. Sometimes, the hardest part of a day was trying to comprehend the challenge, rather than writing the code itself. I wonder if that was a deliberate attempt to make it hard for the puzzles to be solved by LLMs – if the text is tricky for humans to parse, it’s going to be hard for a machine.

LLMs have their uses but, for Advent of Code, where part of the fun is trying to challenge oneself, I preferred to do the coding myself.

Before December 2024

There’s much I want to learn before tackling Advent of Code again this time next year. The need for regular expressions comes up a lot and I’d like to improve my knowledge of those. I was pleased with my Day 1 when I wrote it but, in retrospect, with better regex skills, I would have found it easier, and been able to produce a more efficient solution.

It’s clear that to be successful at Advent of Code puzzles, particularly in the latter stages, I need to know much more about data structures and algorithms. I’ve now bought the book R Data Structures and Algorithms, which seems like a good place to start. I also have the textbook Graphs, Networks and Algorithms which I’ve started to read, though I won’t have the time to work through the whole book in the next eleven months.6

Moreover, from January, I’m going to be participating in a C study group7 which will be working through weeks 1-5 of the CS50 material. Session 3 of that covers algorithms and session 5 teaches data structures, both of which will be useful, no doubt, for Advent of Code. To practice what I’m learning, I am planning, over the next year, to work through the 2015 run of Advent of Code, implementing solutions in both R and C. I’ll update the site as I do.

Last updated

2024-03-26 07:01:08.100755

Details

Session info

Toggle
─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.2 (2023-10-31)
 os       macOS Sonoma 14.3.1
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/London
 date     2024-03-26
 pandoc   3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
 quarto   1.4.533 @ /usr/local/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────
 ! package     * version date (UTC) lib source
 P sessioninfo * 1.2.2   2021-12-06 [?] CRAN (R 4.3.0)

 [1] /Users/ellakaye/Rprojs/mine/ellakaye-quarto/renv/library/R-4.3/aarch64-apple-darwin20
 [2] /Users/ellakaye/Library/Caches/org.R-project.R/R/renv/sandbox/R-4.3/aarch64-apple-darwin20/ac5c2659

 P ── Loaded and on-disk path mismatch.

──────────────────────────────────────────────────────────────────────────────

Footnotes

  1. At least to the extent that family and other commitments would allow.↩︎

  2. Days 1-4, 6-9, 11, 13, 15, 24↩︎

  3. Days 5, 10, 14, 21, 23, 25↩︎

  4. As of December 26th, it was enough to get me to 13th place on the #RStats AOC leaderboard.↩︎

  5. vector("list", n)↩︎

  6. I got over-excited a few years ago when my local bookshop (the wonderful Blackwell’s in Oxford) had a sale on Springer books. I bought several and am always glad when I have reason to return to any of them.↩︎

  7. Details are being finalised but I’ll come back and add a link once I have one.↩︎

Reuse

Citation

BibTeX citation:
@online{kaye2023,
  author = {Kaye, Ella},
  title = {Advent of {Code} 2023 Wrap Up},
  date = {2023-12-30},
  url = {https://ellakaye.co.uk/posts/2023-12-30_advent-of-code-2023},
  langid = {en}
}
For attribution, please cite this work as:
Kaye, Ella. 2023. “Advent of Code 2023 Wrap Up.” December 30, 2023. https://ellakaye.co.uk/posts/2023-12-30_advent-of-code-2023.