2021-12-07 10:52:02 +01:00
2021-12-07 09:49:43 +01:00
2021-12-07 09:49:43 +01:00
2021-12-07 09:49:43 +01:00
2021-12-02 09:19:03 +01:00
2021-12-01 22:46:23 +01:00
2021-12-07 09:49:43 +01:00
2021-12-07 09:49:53 +01:00
2021-12-07 09:49:53 +01:00
2021-12-07 10:52:02 +01:00
2021-12-06 23:39:16 +01:00
2021-12-01 23:02:24 +01:00

Advent of Code 2021

In this repository, you'll find my solutions.

CI

🛠 Setup and running

  • Run composer install to install the dependencies.
  • Run ./aoc21 {day} to run the solution for a specific day (for example ./aoc21 1 to run the code for day 1)
  • Run ./aoc21 puzzle {day} to get the description of the puzzle for the specific day.
  • Run composer test to automatically validate the solutions.

🧩 Add a new puzzle/solution

  • Create a directory in ./data with the correct name.
    • 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 to easily convert the puzzle to markdown.
  • Create a new class in the src directory and make sure it has the structure defined below.
  • Add this class to the ./aoc21 file, and you can run it.
  • Add a new test in ./tests with structure defined below.
  • Run composer test to run all the tests.
Solution command structure
<?php

namespace AdventOfCode21;

// Make sure the classname is correct.
class Day1 extends AbstractCommand
{
  // Update this to the day number.
  protected static int $day = 1;

  protected function part1(array $data): int
  {
      // Solution for part 1.
  }

  protected function part2(array $data): int
  {
    // Solution for part 2.
  }
}
Solution test structure
<?php

namespace Tests;

// Make sure the classname is correct.
class Day1Test extends AbstractTestCase
{
    // Provide the expected results for part 1.
    public static int $part1ExampleResult = 7;
    public static int $part1Result = 1688;

    // Provide the expected results for part 2.
    public static int $part2ExampleResult = 5;
    public static int $part2Result = 1728;

    // Make a new instance of the command with the 'ReturnTestableResults' trait.
    public function setupDay(): Day1
    {
        return new class() extends Day1 {
            use ReturnTestableResults;
        };
    }
}

Description
My Advent of Code framework and solutions
Readme MIT 2 MiB
Languages
PHP 100%