PHP solutions to Advent of Code tasks.
All tasks are Advent of Code ownership. This repository represents my solutions to Advent of Code algorithmic tasks using PHP.
-
Puzzles, e.g.
src/Puzzle/Year[YEAR]/Day[DAY]_TaskName Part1.php # Part1 solution Part2.php # Part2 solution
-
Tests, e.g.
tests/Puzzle/Year[YEAR]/Day[DAY]_TaskName Part1Test.php # Part1 solution test Part2Test.php # Part2 solution test
adventofcode-php is completely dockerized.
If you have docker installed:
- Pull adventofcode-php project
- Open console and change directory to project root
- Run the following command:
docker-compose up -d
- If you need to enter a running container:
docker exec -it adventofcode-php_app_1 /bin/bash
- New puzzle needs to be added in
src/Puzzle/Year2020/Day1DescriptionOptional/Part1.php
directory - Puzzle solution method needs to inherit
App\Puzzle\PuzzleInterface
interface - Puzzle can be run from project root using CLI command
puzzle:run <year> <day> <part> <puzzle_input>
e.g.
php bin/console puzzle:run 2020 1 1 '91212129'
- Also you can open puzzle in your favorite browser, e.g.
http://localhost/src/Puzzle/Year2020/Day1DescriptionOptional/Part1.php
Multiline input can be pasted to CLI using quotes. Both single quotes and double quotes work.
php bin/console puzzle:run 2020 1 1 '1721
979
366
299
675
1456'
PHPUnit is used for testing puzzles also:
Tests can be run using command:
./vendor/bin/phpunit tests/
Copyright (c) 2021 Ivan Georgiev Licensed under the MIT License