-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
41 lines (32 loc) · 1.1 KB
/
index.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
<?php
require_once('SolutionInterface.php');
$problem = isset($_GET['problem']) && ctype_digit($_GET['problem']) ? $_GET['problem'] : null;
ini_set('max_execution_time', 180);
ini_set('Display_errors', 'on');
error_reporting(E_ALL ^ E_NOTICE);
if ($problem == null) {
// Show small index
$dirList = glob('[0-9]*', GLOB_ONLYDIR);
sort($dirList, SORT_NUMERIC);
echo '<h1>Problem overview</h1>';
echo '<ul>';
foreach ($dirList as $dir) {
echo '<li><a href="./?problem=' . $dir . '">Problem #' . $dir . '</a>';
}
echo '</ul>';
} else if ($problem != null && is_dir($problem)) {
$solutionFile = $problem . '/Solution.php';
if (file_exists($solutionFile)) {
require_once($solutionFile);
$solution = new Solution();
// benchmark execution time
$start = microtime(true);
echo $solution->solve();
$end = microtime(true);
echo '<p>Execution time: ' . round($end - $start, 3) . 's</p>';
} else {
echo 'Problem not implemented yet';
}
} else {
echo 'This particular Euler problem has not been solved yet';
}