Awesome
Advent of Code Kotlin - Project Template
This is a self-contained starter project template for solving Advent of Code puzzles in Kotlin! It uses AocKt and Kotest to minimize boilerplate and provide a smooth development experience.
🏗️ Use This Template
- Make sure you're logged in to GitHub
- Click the green Use this template button (not fork!).
- Select Create a new repository.
- Choose yourself as the owner, a descriptive name, and a visibility(*).
- Click Create repository.
- Clone your repository, and open the project with IntelliJ IDEA.
- Solve puzzles!
[!CAUTION] (*) DO NOT Commit Puzzle Inputs On Public Repos!
It is against the rules to redistribute your puzzle inputs!
Inputs are intentionally git-ignored by default. This means that you would have to re-download your inputs and solutions every time you clone from a different machine. To avoid that, use something like
git-crypt
to ensure inputs can only be read by you if you plan on sharing your repository publicly.
📝 Workflow Example
A step-by-step tutorial workflow is documented here.
It covers:
- The project file structure;
- How to add inputs and solutions;
- How to write tests and interpret their output;
- How to use the DSL to solve puzzles.
▶️ Running your Code
From IntelliJ (Recommended)
If you have the Kotest Plugin installed, the IDE will show a
'Run' gutter icon near any AdventSpec
in your code.
After that, you can re-run the same test using Ctrl+F5
, or pressing the Rerun button in the test tool window.
This provides the most comfortable feedback loop when solving new problems.
You may also run tests in bulk by right clicking on a test package.
From Gradle / CLI
You can also run your tests from Gradle.
To run a specific test, pass it via its FQN:
./gradlew test --tests 'aockt.y9999.Y9999D01Test'
You may also filter and run tests in bulk. For example, running all tests within the same year package:
./gradlew test --tests 'aockt.y9999.*'
If for whatever reason you want to run tests in bulk but skip the parts that have been marked as expensive, you can filter them out as well:
./gradlew test -Dkotest.tags='!Expensive'