For the last three years, I've blogged my approaches to the Advent of Code puzzles on my personal site. Assuming I hold true to form, each blog post will include code and commentary on my thinking behind the approach, my thoughts about the puzzles, and vain attempts at wit.
This year, I'm using Kotlin! Much like Rust and Julia in prior years, Kotlin is a new language for me. Given the popularity of the language and the (relatively) easy access it promises to provide for mobile app development, it seemed like a good language to learn.
<project root>
├─src
│ ├─main
│ │ ├─dev.ericburden.aoc2023
│ │ │ ├─Day##.kt
│ │ │ └─Resources.kt
│ │ └resources
│ │ └─day##.txt
│ └─test
│ ├─dev.ericburden.aoc2023
│ │ └─Day##Test.kt
│ └resources
│ └─day##ex##.txt
├─setup-day
├─pom.xml
└─README.md
There are a few organizational notes to point out here:
- Each day includes code in
src/main/dev/ericburden/aoc2023/Day##.kt
and the associated tests insrc/test/dev/ericburden/aoc2023/Day##Test.kt
. EachDay##.kt
file contains a singleDay##
class with aparsed
private value representing the parsed input andsolvePart1()
andsolvePart2()
member functions. There may be other helper functions, attributes, or inner classes as needed to support readability. - The
Resources.kt
file defines theResources
object, used for accessing the input files and example input files. This object has a few convenience methods for accessing this file as a single string, a list of strings by line, a list of numeric values by line, etc. - Input files are stored in
src/main/resources
, named by day. Examples from the puzzle text are stored insrc/test/resources
, named by day and by the order in which the example appears in the text. Both are accessible through theResources
object.
This project uses Maven as the build system. Dependencies can be installed with
mvn compile
. Run all tests with mvn test
. More to come in this section as
I discover more functionality :D.
This project also include a setup-day
bash script that leverages the
aoc-cli
Rust CLI tool to create
the days' class and test files, download the input files, name them, and
place them in the correct folder. The script can be invoked as
setup-day {day}
.