AoC 2020 provided the perfect opportunity to try a new language, so I decided to use Kotlin.
I tried to make the code as clean and easy to read as possible, and I've also provided a short explanation to most solutions so that they're easier to understand.
The corresponding files for each solution are grouped within a dayXX package.
Each solution implements the GenericSolution interface and must implement the runPart1 and runPart2 methods which return the result as a string.
Each test extends the GenericSolutionTest class and must specify the expected results under expectedPart1Result and expectedPart2Result, which keeps the tests very clean.
The corresponding files for each puzzle are located within a dayXX folder.
Each folder contains:
- puzzle.txt: a dump of the puzzle text from the website, with the source link at the top
- input.txt: the puzzle input I received
You can run all the tests using gradle:
./gradlew test
or if you're using Windows:
gradlew.bat test
You can also take advantage of the functionality implemented in main.kt to run the puzzles individually:
./gradlew run --args='<day> <part>'
or if you're using Windows:
gradlew.bat run --args="<day> <part>"
replacing <day>
with the puzzle's day number and <part>
with either 1 or 2.