Skip to content

Commit

Permalink
Load custom inputs for input matrix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneMcC committed Dec 8, 2018
1 parent 15188b5 commit 8206d2b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions inputMatrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8206d2b

Please sign in to comment.