-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoc.php
executable file
·47 lines (37 loc) · 1.22 KB
/
aoc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace App\Aoc;
// region setup
use App\Aoc\Progress\Progress;
use App\Aoc\Runner\RequiresMemoryLimit;
use App\Aoc\Runner\Runner;
require_once __DIR__ . '/vendor/autoload.php';
ini_set('error_reporting', E_ALL & ~E_DEPRECATED);
/** @var InputFetcher $fetcher */
$fetcher = require 'config/fetcher.php';
/** @var SolutionFactory $factory */
$factory = require 'config/solutionFactory.php';
/** @var Runner $runner */
$runner = require 'config/runner.php';
// endregion
Progress::dieAfter((int)getenv('MAX_ITERATIONS'));
$challenge = $factory->mostRecentChallenge();
if (2 === count($argv)) {
$challenge = $challenge->secondPart();
}
if (4 === count($argv)) {
$challenge = Challenge::fromArgv($argv);
}
$solution = $factory->make($challenge);
$input = $fetcher->fetch($challenge);
if ($solution instanceof RequiresMemoryLimit) {
$limit = $solution->getRequiredMemoryLimit();
echo "Increasing memory limit to $limit\n";
ini_set('memory_limit', $limit);
}
echo $challenge, "\n", '---', "\n\n";
if ($input->sample) {
$runner->run($solution, $challenge, 'sample', $input->sample, $input->expected);
}
$runner->run($solution, $challenge, 'challenge', $input->actual);