From: Jan "Yenya" Kasprzak Date: Tue, 2 Dec 2025 06:03:41 +0000 (+0100) Subject: Shorter solution for part 2 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=18c9417edeaa6482730ebce18e1ba47dfb89cb8a;p=aoc.git Shorter solution for part 2 --- diff --git a/2025/04.pl b/2025/04.pl index 36c4b97..4ede8a8 100755 --- a/2025/04.pl +++ b/2025/04.pl @@ -4,8 +4,6 @@ use v5.42; my $sum; for my ($x, $y) (<> =~ /\d+/g) { - for ($x .. $y) { - $sum += $_ if /^(\d+)\1+$/; - } + $sum += $_ for grep /^(\d+)\1+$/, $x .. $y; } say $sum;