🎉 Starts day 1
This commit is contained in:
commit
db1e4575c7
3 files changed
+32
No files matched your search
@@ -0,0 +1,12 @@
|
||||
<?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
|
||||
));
|
||||
Reference in new issue
Block a user