2021-12-09 22:41:22 +01:00
# Advent of Code
2021-12-01 22:46:07 +01:00
2022-11-29 19:58:57 +01:00
[](https://drone.trizz.io/trizz/adventofcode)
2021-12-01 22:46:07 +01:00
2022-11-29 19:58:57 +01:00
In this repository, you'll find my Advent of Code framework and solutions. If you want to
use this framework for your own solution, just remove all data in the `./data` folder and all
2023-12-01 12:03:16 +01:00
folders for each year in the `./src` folder (for example `./src/Y21` , `./src/Y23` , etc.)
2021-12-01 23:01:24 +01:00
2021-12-01 22:46:07 +01:00
## 🛠 Setup and running
- Run `composer install` to install the dependencies.
2023-12-01 12:03:16 +01:00
- Run `./aoc day {day} {year?}` to run the solution for a specific day. If year is not given, use the current year (for example `./aoc day 1` to run the code for day 1 2023)
2022-11-29 19:58:57 +01:00
- Run `./aoc puzzle {day} {year?}` to get the description of the puzzle for the specific day.
2021-12-01 22:46:07 +01:00
- Run `composer test` to automatically validate the solutions.
## 🧩 Add a new puzzle/solution
2021-12-09 22:41:22 +01:00
- Create a directory in `./data/Y??/day?` with the correct name.
2021-12-01 22:46:07 +01:00
- Create `example.txt` with the example values from the puzzle.
- Create `data.txt` with your personal input.
2022-11-29 19:58:57 +01:00
- Create `puzzle.md` with the puzzle description. You can use [this plugin ](https://github.com/kfarnung/aoc-to-markdown ) to easily convert the puzzle to markdown.
- Create a new class in the `src/Y??/Day??.php` directory and make sure it has the structure defined below.
2021-12-01 22:46:07 +01:00
- Run `composer test` to run all the tests.
< details >
2022-11-29 19:58:57 +01:00
< summary > Solution structure< / summary >
2021-12-01 22:46:07 +01:00
```php
< ?php
2021-12-09 22:41:22 +01:00
namespace trizz\AdventOfCode\Y21;
2021-12-01 22:46:07 +01:00
// Make sure the classname is correct.
2021-12-09 22:41:22 +01:00
class Day1 extends Solution
2021-12-01 22:46:07 +01:00
{
2021-12-09 22:41:22 +01:00
// Provide the expected results for part 1.
public static int $part1ExampleResult = null;
public static int $part1Result = null;
// Provide the expected results for part 2.
public static int $part2ExampleResult = null;
public static int $part2Result = null;
2021-12-01 22:46:07 +01:00
protected function part1(array $data): int
{
// Solution for part 1.
}
protected function part2(array $data): int
{
// Solution for part 2.
}
}
```
< / details >