1
0

AdventOfCode /list view kinda finished

This commit is contained in:
Mike Schwörer 2019-11-03 00:06:25 +01:00
parent e00edb7425
commit 65f75c26ef
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
11 changed files with 367 additions and 9 deletions

View File

@ -1125,6 +1125,102 @@ html, body {
flex-direction: row; flex-direction: row;
} }
} }
/* 400px */
.aoc_calendar_parent {
display: flex;
justify-content: center;
margin-top: 1em;
padding-bottom: 1.5em;
}
.aoc_calendar_header {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 0.5em;
background: #F8B229;
}
.aoc_calendar_header_link {
display: flex;
color: #000000;
text-decoration: none;
}
.aoc_calendar_header_title {
flex-grow: 0;
display: flex;
color: #000000;
font-family: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: bold;
}
.aoc_calendar_header_link.aoc_prev {
flex-grow: 0;
padding-left: 0.5em;
}
.aoc_calendar_header_link.aoc_next {
flex-grow: 0;
padding-right: 0.5em;
}
.aoc_calendar_header_link.aoc_link_hidden {
visibility: hidden;
}
.aoc_calendar {
display: flex;
flex-direction: column;
background: #EFEFEF;
font-size: xx-large;
font-family: Consolas, Monaco, "Courier New", Menlo, monospace;
border: 1px solid #000000;
padding-bottom: 0.5em;
}
.aoc_calendar_row {
display: flex;
flex-direction: row;
justify-content: center;
margin-left: 0.5em;
margin-right: 0.5em;
}
.aoc_calendar_field {
display: flex;
align-items: center;
justify-content: center;
width: 2em;
height: 2em;
margin: 4px;
text-decoration: none;
font-weight: bold;
}
.aoc_calendar_field.aoc_enabled {
background: #165B33;
color: #BB2528;
border: 1px solid #FFFFFF;
text-shadow: 0 0 0.2em #222;
font-weight: bold;
}
.aoc_calendar_field.aoc_enabled:hover {
background: #165B00;
color: #BB2528;
border: 1px solid #BB2528;
text-shadow: 0 0 0 #000;
}
.aoc_calendar_field.aoc_disabled {
background: #444;
color: #888;
border: 1px solid #888;
cursor: default;
font-weight: normal;
}
/* 400px */ /* 400px */
.prgl_parent { .prgl_parent {
display: flex; display: flex;

View File

@ -219,6 +219,19 @@ html,body{margin:0;padding:0;height:100%}
.bce_pag10{flex-direction:row} .bce_pag10{flex-direction:row}
.bce_pag05{flex-direction:row} .bce_pag05{flex-direction:row}
} }
.aoc_calendar_parent{display:flex;justify-content:center;margin-top:1em;padding-bottom:1.5em}
.aoc_calendar_header{display:flex;flex-direction:row;justify-content:space-between;margin-bottom:.5em;background:#f8b229}
.aoc_calendar_header_link{display:flex;color:#000;text-decoration:none}
.aoc_calendar_header_title{flex-grow:0;display:flex;color:#000;font-family:Lato,"Helvetica Neue",Helvetica,Arial,sans-serif;font-weight:bold}
.aoc_calendar_header_link.aoc_prev{flex-grow:0;padding-left:.5em}
.aoc_calendar_header_link.aoc_next{flex-grow:0;padding-right:.5em}
.aoc_calendar_header_link.aoc_link_hidden{visibility:hidden}
.aoc_calendar{display:flex;flex-direction:column;background:#efefef;font-size:xx-large;font-family:Consolas,Monaco,"Courier New",Menlo,monospace;border:1px solid #000;padding-bottom:.5em}
.aoc_calendar_row{display:flex;flex-direction:row;justify-content:center;margin-left:.5em;margin-right:.5em}
.aoc_calendar_field{display:flex;align-items:center;justify-content:center;width:2em;height:2em;margin:4px;text-decoration:none;font-weight:bold}
.aoc_calendar_field.aoc_enabled{background:#165b33;color:#bb2528;border:1px solid #fff;text-shadow:0 0 .2em #222;font-weight:bold}
.aoc_calendar_field.aoc_enabled:hover{background:#165b00;color:#bb2528;border:1px solid #bb2528;text-shadow:0 0 0 #000}
.aoc_calendar_field.aoc_disabled{background:#444;color:#888;border:1px solid #888;cursor:default;font-weight:normal}
.prgl_parent{display:flex;flex-direction:column} .prgl_parent{display:flex;flex-direction:column}
@media(max-width:850px){.prgl_parent{align-items:center}} @media(max-width:850px){.prgl_parent{align-items:center}}
.prgl_elem{display:flex;flex-direction:row;text-decoration:none;background:#BBB;border:solid 1px #444;margin:5px 0} .prgl_elem{display:flex;flex-direction:row;text-decoration:none;background:#BBB;border:solid 1px #444;margin:5px 0}

View File

@ -10,6 +10,7 @@
@import 'styles_bloglist'; @import 'styles_bloglist';
@import 'styles_blogview'; @import 'styles_blogview';
@import 'styles_blogview_euler'; @import 'styles_blogview_euler';
@import 'styles_blogview_aoc';
@import 'styles_programslist'; @import 'styles_programslist';
@import 'styles_programsview'; @import 'styles_programsview';

View File

@ -0,0 +1,120 @@
@import 'styles_config';
$COL_CHRISTMAS_YELLOW: #F8B229;
$COL_CHRISTMAS_WHITE: #EFEFEF;
$COL_CHRISTMAS_GREEN: #165B33;
$COL_CHRISTMAS_GREEN_ALT: #165B00;
$COL_CHRISTMAS_RED: #BB2528;
// ==================== AdventOfCode Blog Listing ==================== //
.aoc_calendar_parent {
display: flex;
justify-content: center;
margin-top: 1em;
padding-bottom: 1.5em;
}
.aoc_calendar_header {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 0.5em;
background: $COL_CHRISTMAS_YELLOW;
}
.aoc_calendar_header_link {
display: flex;
color: #000000;
text-decoration: none;
}
.aoc_calendar_header_title {
flex-grow: 0;
display: flex;
color: #000000;
font-family: $FONT_HEADER;
font-weight: bold;
}
.aoc_calendar_header_link.aoc_prev {
flex-grow: 0;
padding-left: 0.5em;
}
.aoc_calendar_header_link.aoc_next {
flex-grow: 0;
padding-right: 0.5em;
}
.aoc_calendar_header_link.aoc_link_hidden {
visibility: hidden;
}
.aoc_calendar {
display: flex;
flex-direction: column;
background: $COL_CHRISTMAS_WHITE;
font-size: xx-large;
font-family: $FONT_CODE;
border: 1px solid #000000;
padding-bottom: 0.5em;
}
.aoc_calendar_row {
display: flex;
flex-direction: row;
justify-content: center;
margin-left: 0.5em;
margin-right: 0.5em;
}
.aoc_calendar_field {
display: flex;
align-items: center;
justify-content: center;
width: 2em;
height: 2em;
margin: 4px;
text-decoration: none;
font-weight: bold;
}
.aoc_calendar_field.aoc_enabled {
background: $COL_CHRISTMAS_GREEN;
color: $COL_CHRISTMAS_RED;
border: 1px solid #FFFFFF;
text-shadow: 0 0 0.2em #222;
font-weight: bold;
}
.aoc_calendar_field.aoc_enabled:hover {
background: $COL_CHRISTMAS_GREEN_ALT;
color: $COL_CHRISTMAS_RED;
border: 1px solid $COL_CHRISTMAS_RED;
text-shadow: 0 0 0 #000;
}
.aoc_calendar_field.aoc_disabled {
background: #444;
color: #888;
border: 1px solid #888;
cursor: default;
font-weight: normal;
}
// ==================== AdventOfCode Blog - Single Day View ==================== //

View File

@ -0,0 +1,62 @@
<?php
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/blog.php');
require_once (__DIR__ . '/../internals/adventofcode.php');
$year = $post['extras']['aoc:year'];
$assocdays = AdventOfCode::listSingleYearAssociative($year);
$prev_year = AdventOfCode::getPrevYear($year);
$next_year = AdventOfCode::getNextYear($year);
?>
<div class="boxedcontent blogcontent_plain">
<div style="position: relative;">
<a href="<?php echo AdventOfCode::getGithubLink($year); ?>" style="position: absolute; top: 0; right: 0; border: 0;">
<img src="/data/images/blog/github_band.png" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>
</div>
<div class="bc_header">
<?php echo $post['date']; ?>
</div>
<div class="bc_data">
<?php echo nl2br(Blog::getPostFragment($post)); ?>
<div class="aoc_calendar_parent">
<div class="aoc_calendar">
<div class="aoc_calendar_header">
<?php
if ($prev_year !== null) echo '<a href="' . AdventOfCode::getURLForYear($prev_year) . '" class="aoc_calendar_header_link aoc_prev" >&lt;</a>';
else echo '<a href="#" class="aoc_calendar_header_link aoc_prev aoc_link_hidden" >&lt;</a>';
echo '<span class="aoc_calendar_header_title">'.$year.'</span>';
if ($next_year !== null) echo '<a href="' . AdventOfCode::getURLForYear($next_year) . '" class="aoc_calendar_header_link aoc_next" >&gt;</a>';
else echo '<a href="" class="aoc_calendar_header_link aoc_next aoc_link_hidden" >&gt;</a>';
?>
</div>
<?php
for ($i=0; $i<5; $i++)
{
echo '<div class="aoc_calendar_row">'."\n";
for ($j=0; $j<5; $j++)
{
$day = $assocdays[$i*5+$j];
if ($day === null) echo '<span class="aoc_calendar_field aoc_disabled">'.($i*5+$j+1).'</span>'."\n";
else echo '<a href="'.$day['url'].'" class="aoc_calendar_field aoc_enabled" >'.($i*5+$j+1).'</a>'."\n";
}
echo '</div>'."\n";
}
?>
</div>
</div>
</div>
</div>

View File

@ -11,6 +11,14 @@ class AdventOfCode
const LANGUAGES = const LANGUAGES =
[ [
'cs' => ['ext'=>'linq', 'css'=>'language-csharp', 'name'=>'C#'], 'cs' => ['ext'=>'linq', 'css'=>'language-csharp', 'name'=>'C#'],
'java' => ['ext'=>'java', 'css'=>'language-java', 'name'=>'Java'],
'bef' => ['ext'=>'b93', 'css'=>'language-befungerunner', 'name'=>'Befunge-93+'],
'cpp' => ['ext'=>'cpp', 'css'=>'language-cpp', 'name'=>'C++'],
'pyth' => ['ext'=>'py', 'css'=>'language-python', 'name'=>'Python'],
'rust' => ['ext'=>'rs', 'css'=>'language-rust', 'name'=>'Rust'],
'go' => ['ext'=>'go', 'css'=>'language-go', 'name'=>'Go'],
'js' => ['ext'=>'js', 'css'=>'language-javascript', 'name'=>'Javascript'],
'pas' => ['ext'=>'pas', 'css'=>'language-pascal', 'name'=>'Pascal/Delphi'],
]; ];
public static function listAllFromAllYears() public static function listAllFromAllYears()
@ -26,7 +34,25 @@ class AdventOfCode
{ {
$all = require (__DIR__ . '/../statics/aoc/__all.php'); $all = require (__DIR__ . '/../statics/aoc/__all.php');
return array_map('self::readSingle', $all[$year]); $result = $all[$year];
array_walk($result, function(&$value) use ($year) { $value = self::readSingle($year, $value); });
return $result;
}
public static function listSingleYearAssociative($year)
{
$all = self::listSingleYear($year);
$result = array_fill(0, 25, null);
foreach ($all as $d)
{
$result[$d['day']-1] = $d;
}
return $result;
} }
public static function listYears() public static function listYears()
@ -85,6 +111,38 @@ class AdventOfCode
return null; return null;
} }
public static function getGithubLink($year)
{
return self::YEARS['' . $year]['github'];
}
public static function getURLForYear($year)
{
return '/blog/' . self::YEARS[''.$year]['blog-id'] . '/Advent_of_Code_' . $year . '/';
}
public static function getPrevYear($year)
{
$last = null;
foreach (self::YEARS as $y => $d)
{
if ($y == $year) return $last;
$last = $y;
}
return null;
}
public static function getNextYear($year)
{
$found = false;
foreach (self::YEARS as $y => $d)
{
if ($found) return $y;
if ($y == $year) $found = true;
}
return null;
}
public static function checkConsistency() public static function checkConsistency()
{ {
$warn = null; $warn = null;
@ -104,6 +162,8 @@ class AdventOfCode
if (in_array($aocdata['title'], $titlelist)) return ['result'=>'err', 'message' => 'Duplicate title ' . $aocdata['title']]; if (in_array($aocdata['title'], $titlelist)) return ['result'=>'err', 'message' => 'Duplicate title ' . $aocdata['title']];
$titlelist []= $aocdata['title']; $titlelist []= $aocdata['title'];
if ($aocdata['day'] < 1 || $aocdata['day'] > 25) return ['result'=>'err', 'message' => 'Invali [day]-value title ' . $aocdata['day']];
if (count($aocdata['solutions']) !== $aocdata['parts']) return ['result'=>'err', 'message' => 'Not enough solution-values in day' . $aocdata['day']]; if (count($aocdata['solutions']) !== $aocdata['parts']) return ['result'=>'err', 'message' => 'Not enough solution-values in day' . $aocdata['day']];
if (count($aocdata['file_solutions']) !== $aocdata['parts']) return ['result'=>'err', 'message' => 'Not enough solution-files in day' . $aocdata['day']]; if (count($aocdata['file_solutions']) !== $aocdata['parts']) return ['result'=>'err', 'message' => 'Not enough solution-files in day' . $aocdata['day']];

View File

@ -31,9 +31,9 @@ if ($isSubAdventOfCode)
} }
if ($adventofcodeday === null) $isSubAdventOfCode = false; if ($adventofcodeday === null) $isSubAdventOfCode = false;
$title = $post['title']; $htmltitle = $post['title'];
if ($isSubEuler) $title = $eulerproblem['title']; if ($isSubEuler) $htmltitle = $eulerproblem['title'];
if ($isSubAdventOfCode) $title = $adventofcodeday['title']; if ($isSubAdventOfCode) $htmltitle = $adventofcodeday['title'];
$canonical = $post['canonical']; $canonical = $post['canonical'];
if ($isSubEuler) $canonical = $eulerproblem['canonical']; if ($isSubEuler) $canonical = $eulerproblem['canonical'];
@ -42,7 +42,7 @@ if ($isSubAdventOfCode) $canonical = $adventofcodeday['canonical'];
?> ?>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Mikescher.com - <?php echo $title; ?></title> <title>Mikescher.com - <?php echo $htmltitle; ?></title>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/> <link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<?php printCSS(); ?> <?php printCSS(); ?>
<?php echo '<link rel="canonical" href="' . $canonical . '"/>'; ?> <?php echo '<link rel="canonical" href="' . $canonical . '"/>'; ?>

View File

@ -24,6 +24,6 @@ return
[ 'id' => 9, 'date' => '2016-10-22', 'visible' => true, 'title' => 'A complete sudoku solver in Befunge-93', 'fragment' => 'sudoku_befunge.md', 'type' => 'markdown', 'cat' => 'blog' ], [ 'id' => 9, 'date' => '2016-10-22', 'visible' => true, 'title' => 'A complete sudoku solver in Befunge-93', 'fragment' => 'sudoku_befunge.md', 'type' => 'markdown', 'cat' => 'blog' ],
[ 'id' => 21, 'date' => '2018-01-02', 'visible' => true, 'title' => 'A simple javascript befunge-93 runner', 'fragment' => 'js_befrunner.md', 'type' => 'markdown', 'cat' => 'blog' ], [ 'id' => 21, 'date' => '2018-01-02', 'visible' => true, 'title' => 'A simple javascript befunge-93 runner', 'fragment' => 'js_befrunner.md', 'type' => 'markdown', 'cat' => 'blog' ],
[ 'id' => 22, 'date' => '2018-02-06', 'visible' => true, 'title' => 'Homepage iteration 5', 'fragment' => 'v5.md', 'type' => 'markdown', 'cat' => 'log' ], [ 'id' => 22, 'date' => '2018-02-06', 'visible' => true, 'title' => 'Homepage iteration 5', 'fragment' => 'v5.md', 'type' => 'markdown', 'cat' => 'log' ],
[ 'id' => 23, 'date' => '2019-11-02', 'visible' => true, 'title' => 'Advent of Code 2018', 'fragment' => '', 'type' => 'aoc', 'cat' => 'blog', 'extras' => ['aoc:year' => '2018'] ], [ 'id' => 23, 'date' => '2019-11-02', 'visible' => true, 'title' => 'Advent of Code 2018', 'fragment' => 'aoc2018.txt', 'type' => 'aoc', 'cat' => 'blog', 'extras' => ['aoc:year' => '2018'] ],
[ 'id' => 24, 'date' => '2019-12-01', 'visible' => false, 'title' => 'Advent of Code 2019', 'fragment' => '', 'type' => 'aoc', 'cat' => 'blog', 'extras' => ['aoc:year' => '2019'] ], [ 'id' => 24, 'date' => '2019-12-01', 'visible' => false, 'title' => 'Advent of Code 2019', 'fragment' => 'aoc2019.txt', 'type' => 'aoc', 'cat' => 'blog', 'extras' => ['aoc:year' => '2019'] ],
]; ];

View File

@ -0,0 +1,5 @@
This is the first year I'm participating in the advent of code programming challenges.
I intend to solve the puzzles with C# and Linqpad 5, just because that's the configuration I'm most confortable at writing small one-off scripts.
If you haven't solved them by yourself be aware that clicking on the days below will spoiler the solutions and the second daily challenges...

View File

@ -0,0 +1 @@
//TODO ENTER TEXT HERE