adventofcode/README.md

55 lines
1.8 KiB
Markdown
Raw Normal View History

# Advent of Code
2021-12-01 22:46:07 +01:00
In this repository, you'll find my solutions.
2021-12-01 23:01:24 +01:00
[![CI](https://github.com/trizz/adventofcode21/actions/workflows/ci.yaml/badge.svg)](https://github.com/trizz/adventofcode21/actions/workflows/ci.yaml)
2021-12-01 22:46:07 +01:00
## 🛠 Setup and running
- Run `composer install` to install the dependencies.
- Run `./aoc {day} {year?}` to run the solution for a specific day. If year is not given, use the current year (for example `./aoc 1` to run the code for day 1 2021)
- Run `./aoc21 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
- 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.
- Create `puzzle.md` with the puzzle. 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??/` directory and make sure it has the structure defined below.
- Add this class to the `./aoc` file, and you can run it.
2021-12-01 22:46:07 +01:00
- Add a new test in `./tests` with structure defined below.
- Run `composer test` to run all the tests.
<details>
<summary>Solution command structure</summary>
```php
<?php
namespace trizz\AdventOfCode\Y21;
2021-12-01 22:46:07 +01:00
// Make sure the classname is correct.
class Day1 extends Solution
2021-12-01 22:46:07 +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>