This repository contains solutions for the Advent of Code 2024 puzzles written in Java.
Prerequisites:
- Java 23 or later: (https://www.oracle.com/java/technologies/javase-downloads.html)
- A code editor or IDE (e.g., IntelliJ IDEA, Eclipse)
Running the Solutions:
Each day's solution is a separate Java class located in the src/
directory. The class name follows the format DayXX.java
, where XX is the day number.
To run a solution:
- Download the input data for the desired day from Advent of Code (https://adventofcode.com/2024).
- Place the input data in a file named
inputXX.txt
in the root directory of this repository, where XX is the day number. - Open a terminal or command prompt and navigate to the root directory of the repository.
- Execute the desired solution class:
java src/DayXX.java
src/Measure.java
provides a simple way to measure the performance of a puzzle solution. It offers the following features:
- Configurable Iterations: Customize the number of iterations to fine-tune your benchmarks.
- Warmup Phase: Ensures accurate measurements by running a warmup phase to eliminate initial overhead.
- Human-Readable Output: Displays results in clear units (seconds, milliseconds, microseconds, etc.) for easy interpretation.
- Modular Design: Easily add new solutions to be benchmarked by implementing the
Solution
interface.
Parameters
- --loops: Specifies the number of iterations for the benchmark. Default: 10.
How to Use
- Implement Your Solution: Create a class that implements the
Solution
interface and define itscall
method to execute your solution logic. - Add Your Solution to
SOLUTIONS
: Add your solution class to theSOLUTIONS
array in theMeasure
class. - Run the Benchmark: Execute the
Measure
class with the desired day number as an argument, optionally specifying the--loops
parameter.
Example:
java src/Measure.java --loops 100 1
This will benchmark the solution for Day 1 with 100 iterations.