Files
advent_of_code_2021/08/part1.php
2021-12-08 18:09:11 +01:00

11 lines
329 B
PHP

<?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