13 lines
394 B
PHP
13 lines
394 B
PHP
<?php
|
|
|
|
$lines = array_filter(explode("\n", file_get_contents('./input.txt')), fn($line) => !empty($line));
|
|
|
|
echo array_sum(array_map(
|
|
static function($line) {
|
|
$numbers = array_values(array_filter(array_map(static fn($letter) => is_numeric($letter) ? $letter : null, str_split($line))));
|
|
|
|
return (int) sprintf('%s%s', $numbers[0], array_pop($numbers));
|
|
},
|
|
$lines
|
|
));
|