Welcome to the repository containing my solutions for Advent of Code, an annual coding event that takes place every December. Each day, a new programming challenge is released, and this repository contains my attempts to solve those challenges.
The repository is organized as a Java project with a submodule named solutions and one called annotation-scanner.
The annotation scanner module supports
the generation of the
DaySolver
class for each year.
This annotation scanner will add an instance of the DaySolver in the bean context registry.
Automated test generation is done using the generation test classes per year with test cases for each case. A test case is determined by files in the following location:
test/resources/input/%year%/day_%day%_%test-case%
Where the year and day are substituted with the year and day of the challenge, and the test-case is the name of the test case.
The solutions module includes a package com.github.gjong.advent
with subpackages for each year, prefixed with a 'y',
and additional subpackages for shared
logic: common, algo,
and geo.
advent-of-code/
├── solutions/
│ ├── src/
│ │ └── main/
│ │ └── java/
│ │ └── com/
│ │ └── github/
│ │ └── gjong/
│ │ └── advent/
│ │ ├── years/
│ │ │ ├── y2021/
│ │ │ │ ├── Day01.java
│ │ │ │ ├── Day02.java
│ │ │ | └── ...
│ │ │ └── ...
│ │ ├── common/
│ │ │ └── CharGrid.java
│ │ │ └── InputLoader.java
│ │ │ └── Validator.java
│ │ ├── algo/
│ │ │ └── Algo.java
│ │ ├── geo/
│ │ | └── Bounds.java
│ │ | └── Point.java
│ │ | └── Vector.java
│ │ └── AdventOfCode.java
│ └── gradle.build.kts
├── README.md
├── gradle.build.kts
To run the solutions, you need to have Java 21 or higher installed on your machine. The project is built using Gradle, so you can run the solutions using the following command:
echo "Running solutions for 2021"
./gradlew run --args="-y 2021"
echo "Running solutions for all years"
./gradlew run
The CLI supports the following arguments:
[cli] Execute using the following options:
[cli] -y <year> Execute only the provided year.
[cli] -b Run in benchmark mode.
[cli] -r Number of runs in benchmark mode, default 5.
Each solution is timed using the Instant.now()
method, and the results are displayed in the table below.
The time is measured in milliseconds and includes the time to read the input, run the solution, and validating the
output.
The benchmarking is achieved by running the following command:
echo "Running solutions for 2021"
./gradlew run --args="-y 2021 -b -r 100"
The measurements are taken on an AMD Ryzen 5 3600X CPU with 64GB of RAM.
ℹ️ Click on the name of a solution to go to the related source file.
Year | Day | Name | Parsing | Part 1 | Part 2 | Assignment |
---|---|---|---|---|---|---|
2021 | 01 | Sonar Sweep | - | 828μs | 946μs | instructions |
2021 | 02 | Dive! | - | 1010μs | 653μs | instructions |
2021 | 03 | Binary Diagnostic | - | 484μs | 859μs | instructions |
2021 | 04 | Giant Squid | - | 2ms | 3ms | instructions |
2021 | 05 | Hydrothermal Venture | 11μs | 13ms | 3ms | instructions |
2021 | 06 | Lanternfish | - | 162μs | 190μs | instructions |
2021 | 07 | The Treachery of Whales | - | 932μs | 849μs | instructions |
2021 | 08 | - | 2ms | 2ms | instructions | |
2021 | 09 | Smoke Basin | - | 342μs | 699μs | instructions |
2021 | 10 | Syntax Scoring | - | 482μs | 524μs | instructions |
2021 | 11 | Dumbo Octopus | - | 354μs | 353μs | instructions |
2021 | 12 | Passage Pathing | - | 5ms | 540ms | instructions |
2021 | 13 | Transparent Origami | - | 4ms | 5ms | instructions |
2021 | 14 | Extended Polymerization | - | 7ms | 1194μs | instructions |
2021 | 15 | Chiton | - | 2ms | 279ms | instructions |
2021 | 16 | Packet Decoder | - | 1ms | 1ms | instructions |
2021 | 17 | Trick Shot | 10μs | 5ms | 5ms | instructions |
2021 | 18 | Snailfish | - | 2ms | 81ms | instructions |
2021 | 21 | Dirac Dice | - | 241μs | 11560ms | instructions |
Year | Day | Name | Parsing | Part 1 | Part 2 | Assignment |
---|---|---|---|---|---|---|
2022 | 01 | Calorie Counting | - | 1078μs | 636μs | instructions |
2022 | 02 | Rock Paper Scissors | - | 478μs | 620μs | instructions |
2022 | 03 | Rucksack Reorganization | - | 1187μs | 1ms | instructions |
2022 | 04 | Camp Cleanup | - | 1ms | 1ms | instructions |
2022 | 05 | Supply Stacks | - | 952μs | 1ms | instructions |
2022 | 06 | Tuning Trouble | - | 701μs | 1031μs | instructions |
2022 | 07 | No Space Left On Device | - | 833μs | 1137μs | instructions |
2022 | 08 | Treetop Tree House | - | 1ms | 1ms | instructions |
2022 | 09 | Rope Bridge | - | 1ms | 1ms | instructions |
2022 | 10 | Cathode-Ray Tube | - | 531μs | 257μs | instructions |
2022 | 11 | Monkey in the Middle | - | 603μs | 43ms | instructions |
2022 | 12 | Hill Climbing Algorithm | - | 1ms | 90ms | instructions |
2022 | 13 | Distress Signal | - | 2ms | 2ms | instructions |
2022 | 14 | Regolith Reservoir | - | 1ms | 65ms | instructions |
Year | Day | Name | Parsing | Part 1 | Part 2 | Assignment |
---|---|---|---|---|---|---|
2023 | 01 | Trebuchet?! | - | 986μs | 3ms | instructions |
2023 | 02 | Cube Conundrum | - | 709μs | 747μs | instructions |
2023 | 03 | Gear Ratios | - | 5ms | 3ms | instructions |
2023 | 04 | Scratchcards | - | 1ms | 1ms | instructions |
2023 | 05 | If You Give A Seed A Fertilizer | - | 789μs | 977μs | instructions |
2023 | 06 | Wait For It | - | 180μs | 128μs | instructions |
2023 | 07 | Camel Cards | - | 2ms | 2ms | instructions |
2023 | 08 | Haunted Wasteland | - | 2ms | 2ms | instructions |
2023 | 09 | Mirage Maintenance | - | 1ms | 1ms | instructions |
2023 | 10 | Pipe Maze | - | 15ms | - | instructions |
2023 | 11 | Cosmic Expansion | - | 2ms | 1ms | instructions |
2023 | 12 | Hot Springs | - | 3ms | 24ms | instructions |
2023 | 13 | Point of Incidence | - | 661μs | 490μs | instructions |
2023 | 14 | Parabolic Reflector Dish | - | 5ms | 1539ms | instructions |
2023 | 15 | Lens Library | - | 369μs | 1ms | instructions |
2023 | 16 | The Floor Will Be Lava | - | 2ms | 65ms | instructions |
2023 | 17 | Clumsy Crucible | - | 80ms | 239ms | instructions |
Year | Day | Name | Parsing | Part 1 | Part 2 | Assignment |
---|---|---|---|---|---|---|
2024 | 01 | Historian Hysteria | 20ms | 221μs | 269μs | instructions |
2024 | 02 | Red-Nosed Reports | - | 1ms | 1ms | instructions |
2024 | 03 | Mull it over | - | 606μs | 394μs | instructions |
2024 | 04 | Ceres Search | - | 2ms | 958μs | instructions |
2024 | 05 | Print Queue | 5ms | 2ms | 2ms | instructions |
2024 | 06 | Guard Gallivant | 1119μs | 27ms | 10015ms | instructions |
2024 | 07 | Bridge Repair | - | 32ms | 6863ms | instructions |
2024 | 08 | Resonant Collinearity | 1087μs | 51μs | 111μs | instructions |
2024 | 09 | Disk Fragmenter | - | 1065μs | 89ms | instructions |
2024 | 10 | Hoof it | - | 664μs | 937μs | instructions |
2024 | 11 | Plutonian Pebbles | - | 487μs | 32ms | instructions |
2024 | 12 | Garden Groups | - | 6ms | 10ms | instructions |
2024 | 13 | Claw Contraption | 11ms | 24μs | 67μs | instructions |
2024 | 14 | Restroom Redoubt | - | 19ms | 171ms | instructions |
2024 | 17 | Chronospatial Computer | 1000μs | 110μs | 1ms | instructions |
2024 | 18 | RAM Run | 4ms | 43ms | 2189ms | instructions |
2024 | 19 | Linen Layout | - | 11ms | 56ms | instructions |
2024 | 20 | Race Condition | - | 71ms | 336ms | instructions |