Advent Of Code - Library PHP

dev-master 2021-12-27 13:00 UTC

This package is auto-updated.

Last update: 2024-04-27 18:04:34 UTC


README

Github Advent Of Code php

Table of Contents

Installation

composer require migueabellan/aoc

Basic Usage

Create a .env.local file to make environment variables.

# DO NOT COMMITTED THIS FILE

SESSION_AOC=your_cookie_session

Autoloading

Supports PSR-4 autoloaders.

<?php

// When installed via composer
require_once 'vendor/autoload.php';

use Aoc\Client;

$client = new Client();

// Retrieve input by year and day
$input = $client->getInputBy(2020, 23);

echo $input; // 543769257...

Advanced Usage

<?php

use Aoc\Puzzle\AbstractPuzzle;

class Puzzle extends AbstractPuzzle
{
    public function exec1(array $input = []): int|string
    {
        $result = 0;

        // ...

        return (string)$result;
    }

    public function exec2(array $input = []): int|string
    {
        $result = 0;

        // ...

        return (string)$result;
    }
}

Utils

<?php

use Aoc\Utils;

$array = [0, 1, 2];

$permutations = ArrayUtil::permutations($array);

print_r($permutations); // [[0, 1, 2], [0, 2, 1], [2, 1, 0] ...]