1
0
www.mikescher.com/www/internals/euler.php

41 lines
915 B
PHP
Raw Normal View History

2017-11-08 17:39:50 +01:00
<?php if(count(get_included_files()) ==1) exit("Direct access not permitted.");
class Euler
{
public static function readSingle($f)
{
$a = require $f;
$a['rating'] = self::rateTime($a);
2017-12-31 17:53:59 +01:00
$a['url'] = '/blog/1/Project_Euler_with_Befunge/problem-' . str_pad($a['number'], 3, '0', STR_PAD_LEFT);
$a['canonical'] = "https://www.mikescher.com" . $a['url'];
$a['is93'] = ($a['width'] <= 80 AND $a['height'] <= 25);
2017-11-08 17:39:50 +01:00
return $a;
}
public static function listAll()
{
2017-12-28 22:53:41 +01:00
$expr = __DIR__ . '/../statics/euler/Euler_Problem-*.php';
$files = glob($expr);
2017-11-08 17:39:50 +01:00
return array_map('self::readSingle', $files);
}
public static function rateTime($problem)
{
if ($problem['time'] < 100) // < 100ms
return 0;
if ($problem['time'] < 15 * 1000) // < 5s
return 1;
if ($problem['time'] < 60 * 1000) // < 1min
return 2;
if ($problem['time'] < 5 * 60 * 1000) // < 5min
return 3;
return 4;
}
}