Add day 1 '22 solution
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -14,6 +14,11 @@ abstract class Solution
|
||||
|
||||
public static int|string|null $part2Result = null;
|
||||
|
||||
/**
|
||||
* @var bool When false, do not apply the `array_filter` function when the data is loaded.
|
||||
*/
|
||||
public bool $filterDataOnLoad = true;
|
||||
|
||||
/**
|
||||
* @var string[] The data to use.
|
||||
*
|
||||
@ -60,14 +65,14 @@ abstract class Solution
|
||||
if (file_exists($dataFile)) {
|
||||
$data = file_get_contents($dataFile);
|
||||
if ($data !== false) {
|
||||
$this->data = array_filter(explode(PHP_EOL, $data));
|
||||
$this->data = $this->filterDataOnLoad ? array_filter(explode(PHP_EOL, $data)) : explode(PHP_EOL, $data);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($dataExampleFile)) {
|
||||
$data = file_get_contents($dataExampleFile);
|
||||
if ($data !== false) {
|
||||
$this->exampleData = array_filter(explode(PHP_EOL, $data));
|
||||
$this->exampleData = $this->filterDataOnLoad ? array_filter(explode(PHP_EOL, $data)) : explode(PHP_EOL, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user