Permalink
Browse files

Load custom inputs for input matrix.

  • Loading branch information...
ShaneMcC committed Dec 8, 2018
1 parent 15188b5 commit 8206d2bd9f94da7a8363344f533767f5a5aa3d47
Showing with 22 additions and 0 deletions.
  1. +22 −0 inputMatrix.php
@@ -69,6 +69,28 @@
echo 'Done.', "\n";
}
// Load any custom inputs.
for ($day = 1; $day <= 25; $day++) {
$customDir = $inputsDir . '/custom/' . $day;
$id = 0;
if (file_exists($customDir)) {
foreach (scandir($customDir) as $dir) {
if ($dir{0} == '.') { continue; }
if (file_exists($customDir . '/' . $dir . '/input.txt') && file_exists($customDir . '/' . $dir . '/answers.txt')) {
$answers = file($customDir . '/' . $dir . '/answers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (!isset($answers[1])) { continue; }
$id++;
$inputs[$day]['custom-' . $id]['input'] = file_get_contents($customDir . '/' . $dir . '/input.txt');
$inputs[$day]['custom-' . $id]['version'] = sha1($input);
$inputs[$day]['custom-' . $id]['answer1'] = $answers[0];
$inputs[$day]['custom-' . $id]['answer2'] = $answers[1];
}
}
}
}
chdir($cwd);
// Remove days with no inputs.

0 comments on commit 8206d2b

Please sign in to comment.