- AoC website
- My AoC username:
tbali0524
- Some memes from AoC subreddit
- Puzzle list with topics and my completion status (in PHP)
- Results and running times
- This repo on GitHub
- My AoC solutions in Rust (~4.5 seasons, 218⭐)
This repo contains my AoC solutions in PHP, and a simple CLI runner. The first 9 seasons I originally solved in PHP, and later rewrote some solutions (~3.5 seasons) in Rust. In season 2024 I solved the puzzles first in Rust (and rewrote them in PHP later).
The solutions are using only the standard php library, they have NO 3rd-party package dependencies. However, Composer is used for its class autoloader:
composer install
Note: Some solutions require more memory than what a default PHP installation provides, so it is recommended to set memory_limit = -1
in php.ini
.
Run solutions from the project base directory with:
php src/aoc.php [LANGUAGE] [YEAR] [DAY]
Argument | Effect |
---|---|
LANGUAGE given |
invoke interpreter with standalone solution scripts |
all given as the LANGUAGE |
invoke standalone solution scripts in all languages |
LANGUAGE not given |
invoke class-based PHP solutions |
none of YEAR and DAY given |
run all solutions |
only YEAR given |
run all solutions for that season only |
both YEAR and DAY given |
run a specific solution |
On Windows, the shortcut .\aoc.bat [LANGUAGE] [YEAR] [DAY]
also works.
Possible values for LANGUAGE
:
all, dart, f#, go, groovy, java, javascript, lua, perl, php, python, ruby, scala.
- Directory pattern:
input/YYYY/
, whereYYYY
is the year. - Filename pattern:
AocYYYYDayDD.txt
, whereDD
is the day padded to 2 digits with zero. - Optional additional example input can be in
AocYYYYDayDDex1.txt
,AocYYYYDayDDex2.txt
, etc. - Alternatively, a single string input can be given in the
STRING_INPUT
orEXAMPLE_STRING_INPUTS
constants in the solution class. - Additionally, some extra large input can be given in
AocYYYYDayDDlarge1.txt
,AocYYYYDayDDlarge2.txt
, ...- These will be run ONLY if the
LARGE_SOLUTIONS
constant array is overriden in the solution class.
- These will be run ONLY if the
- Directory pattern:
src/AocYYYY/
. - Filename pattern:
AocYYYYDayDD.php
. - For a new solution, use the template in
src/AocYYYYDayDD.php
. - Solution should implement class
AocYYYYDayDD
, extendingSolutionBase
. - It should implement the
solve()
method and override the constants in the Solution interface. - The
solve()
method must be callable repeatedly with different inputs. - After successful submit, the puzzle answers shall be recorded in the
SOLUTIONS
class constant (for future regression tests).
- Directory pattern:
src/other/AocYYYY/
. - Filename pattern:
AocYYYYDayDD.ext
.- (For
PHP
only: the pattern isAocYYYYDayDDscr.php
to avoid having the same source filename as the class-based solution.)
- (For
- The script shall read the input file (if needed), print the problem ID and the solution.
The following helper commands are defined in composer.json:
Command | Description |
---|---|
start | Run all solutions with AocRunner |
test | Run solutions and create test coverage report with PHPUnit |
cs | Check coding style compliance to PSR12 with PHP_CodeSniffer |
cs-fixer | Check coding style compliance to PSR12 plus extra rules with PHP-CS-Fixer (no fix applied) |
cs-fixer-do | Apply coding style fixes with PHP-CS-Fixer |
doc | Create documentation with phpDocumentor |
lint | Check syntax errors with Parallel-Lint |
loc | Get code summary report with phploc |
metrics | Generate code metrics report with PhpMetrics |
stan | Run static analysis with PHPStan |
qa | Run code quality checks: PHP_CodeSniffer, PHP-CS-Fixer, PHPStan |
qa-full | Run all code quality checks: PHP_CodeSniffer, PHP-CS-Fixer, PHPStan, Parallel-Lint, PhpMetrics, phpDocumentor, PHPUnit, and run all solutions |
open-cover | Open generated test coverage report in browser (fixed file path) |
open-doc | Open generated documentation in browser (fixed file path) |
open-metrics | Open generated code metrics report in browser (fixed file path) |
clean | Delete generated cache and report files in .tools and docs directories (Windows only) |
- The above tools are NOT listed in
composer.json
as dev dependencies. Instead, the commands must be available in thePATH
. See minimum version requirements in the config files. - To run
php-cs-fixer
withphp v8.4
, set thePHP_CS_FIXER_IGNORE_ENV
environment variable to1
. - Currently several dev tools do not run or reports depreciations in
php v8.4
. (doc, loc, metrics)