blogview_euler_single.php (WIP)
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
global $CONFIG;
|
||||
$CONFIG = require 'config.php';
|
||||
|
||||
$CSS_BASE = ($CONFIG['prod']) ? ('styles.min.css') : ('styles.css');
|
||||
|
||||
function startsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
|
||||
@@ -5,10 +5,25 @@ class Euler
|
||||
public static function readSingle($f)
|
||||
{
|
||||
$a = require $f;
|
||||
|
||||
$n3p = str_pad($a['number'], 3, '0', STR_PAD_LEFT);
|
||||
$a['number3'] = $n3p;
|
||||
|
||||
$a['rating'] = self::rateTime($a);
|
||||
$a['url'] = '/blog/1/Project_Euler_with_Befunge/problem-' . str_pad($a['number'], 3, '0', STR_PAD_LEFT);
|
||||
|
||||
$a['url'] = '/blog/1/Project_Euler_with_Befunge/problem-' . $n3p;
|
||||
$a['canonical'] = "https://www.mikescher.com" . $a['url'];
|
||||
|
||||
$a['is93'] = ($a['width'] <= 80 AND $a['height'] <= 25);
|
||||
|
||||
$a['url_euler'] = 'https://projecteuler.net/problem=' . $n3p;
|
||||
$a['url_raw'] = 'https://raw.githubusercontent.com/Mikescher/Project-Euler_Befunge/master/processed/Euler_Problem-' . $n3p . '.b93';
|
||||
$a['url_github'] = 'https://github.com/Mikescher/Project-Euler_Befunge';
|
||||
|
||||
$a['file_description'] = (__DIR__ . '/../statics/euler/Euler_Problem-'.$n3p.'_description.md');
|
||||
$a['file_code'] = (__DIR__ . '/../statics/euler/Euler_Problem-'.$n3p.'.b93');
|
||||
$a['file_explanation'] = (__DIR__ . '/../statics/euler/Euler_Problem-'.$n3p.'_explanation.md');
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
@@ -20,6 +35,14 @@ class Euler
|
||||
return array_map('self::readSingle', $files);
|
||||
}
|
||||
|
||||
public static function getEulerProblem($num)
|
||||
{
|
||||
foreach (self::listAll() as $ep) {
|
||||
if ($ep['number'] == $num) return $ep;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function rateTime($problem)
|
||||
{
|
||||
if ($problem['time'] < 100) // < 100ms
|
||||
|
||||
Reference in New Issue
Block a user