15 lines
399 B
PHP
15 lines
399 B
PHP
|
<?php
|
||
|
|
||
|
$output = array_map(static function ($line) {
|
||
|
return explode('|', $line)[1];
|
||
|
}, explode("\n", file_get_contents('./input.txt')));
|
||
|
|
||
|
echo array_reduce($output, static function($carry, $item) {
|
||
|
$count = 0;
|
||
|
$items = explode(' ', $item);
|
||
|
foreach ($items as $item) {
|
||
|
$count += in_array(strlen($item), [2, 4, 3, 7]) ? 1 : 0;
|
||
|
}
|
||
|
$carry += $count;
|
||
|
return $carry;
|
||
|
});
|