8th day both parts
This commit is contained in:
10
08/part1.php
Normal file
10
08/part1.php
Normal 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
|
||||
Reference in New Issue
Block a user