adventofcode/2023/01/Part1.pm

17 lines
244 B
Perl
Raw Permalink Normal View History

2023-12-01 17:04:34 +00:00
use 5.38.0;
package Part1;
use List::AllUtils qw/ sum /;
sub extract_number ($line) {
my @n = $line =~ /(\d)/g;
return join "", $n[0], $n[-1];
}
sub solution_1 ($input) {
sum map { extract_number($_) } split "\n", $input;
}
1;