Advent of Code 2024 solutions. https://adventofcode.com/
composer install
To get the solution for day 2, run.
./aoc solve 2
To create a new solution for day 28
do the following (replace 28 with the number of your day):
- Store the input in
puzzles/Day28/input.txt
. If the input for part 1 and 2 is not the same, useinput1.txt
andinput2.txt
. - Create a new Solution for the day
puzzles/Day28/Solution.php
That implements theStyxit\PuzzleSolutionInterface
interface. - Write the
solution1(Input $input)
andsolution2(Input $input)
methods that return the solutions for part 1 and part 2.
In the Solution class, the puzzle input is provided as the first argument. Yse $input
to get access to the parsed input.
Solve the puzzle with
./aoc solve 28
The example data for the puzzle can be stored in puzzles/Day28/example.txt
. If the example input for part 1 and 2 is not the same, use example1.txt
and example2.txt
. After that, use the --example
option to use the example data as input.
Solve the puzzle using example data.
./aoc solve 28 --example
For each solution a test can be written to make sure the output is correct. By extending the AbstractDayTester
only the (example) solutions need to be defined. To test the solution for a new day, add a test in the tests/Solutions
dir, call it Day28Test.php
.
<?php
namespace Tests\Solutions;
/**
* @internal
*/
class Day28Test extends AbstractDayTester
{
protected $solutionPart1 = 123;
protected $solutionPart2 = 0; // Part 2 not yet solved.
protected $exampleSolution1 = 456;
protected $exampleSolution2 = 0; // Part 2 not yet solved.
}
Run all tests:
composer test