Skip to content

Commit 8206d2b

Browse files
committed
Load custom inputs for input matrix.
1 parent 15188b5 commit 8206d2b

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎inputMatrix.php‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,28 @@
6969

7070
echo 'Done.', "\n";
7171
}
72+
73+
// Load any custom inputs.
74+
for ($day = 1; $day <= 25; $day++) {
75+
$customDir = $inputsDir . '/custom/' . $day;
76+
$id = 0;
77+
if (file_exists($customDir)) {
78+
foreach (scandir($customDir) as $dir) {
79+
if ($dir{0} == '.') { continue; }
80+
if (file_exists($customDir . '/' . $dir . '/input.txt') && file_exists($customDir . '/' . $dir . '/answers.txt')) {
81+
$answers = file($customDir . '/' . $dir . '/answers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
82+
if (!isset($answers[1])) { continue; }
83+
84+
$id++;
85+
$inputs[$day]['custom-' . $id]['input'] = file_get_contents($customDir . '/' . $dir . '/input.txt');
86+
$inputs[$day]['custom-' . $id]['version'] = sha1($input);
87+
$inputs[$day]['custom-' . $id]['answer1'] = $answers[0];
88+
$inputs[$day]['custom-' . $id]['answer2'] = $answers[1];
89+
}
90+
}
91+
}
92+
}
93+
7294
chdir($cwd);
7395

7496
// Remove days with no inputs.

0 commit comments

Comments
 (0)