8th day both parts

This commit is contained in:
kplaczek
2021-12-08 18:09:11 +01:00
parent 5f33713103
commit 387687d054
4 changed files with 267 additions and 1 deletions

10
08/part1.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
$input = file('input', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$input = array_map(fn($line) => explode(' ', explode(' | ', $line)[1]), $input);
$digits = 0;
foreach ($input as $segments) {
$digits += count(array_filter($segments, fn($segment) => in_array(strlen($segment), [2,4,3,7])));
}
echo $digits; //303