From: Jan "Yenya" Kasprzak Date: Tue, 2 Dec 2025 05:37:51 +0000 (+0100) Subject: Day 2: regex with backrefs X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=7243b12cd45da274dc836bea4dfa17b33b81b536;p=aoc.git Day 2: regex with backrefs --- diff --git a/2025/03.pl b/2025/03.pl new file mode 100755 index 0000000..9e4a966 --- /dev/null +++ b/2025/03.pl @@ -0,0 +1,11 @@ +#!/usr/bin/perl -w + +use v5.42; + +my $sum; +for my ($x, $y) (<> =~ /\d+/g) { + for ($x .. $y) { + $sum += $_ if /^(\d+)\1$/; + } +} +say $sum; diff --git a/2025/04.pl b/2025/04.pl new file mode 100755 index 0000000..36c4b97 --- /dev/null +++ b/2025/04.pl @@ -0,0 +1,11 @@ +#!/usr/bin/perl -w + +use v5.42; + +my $sum; +for my ($x, $y) (<> =~ /\d+/g) { + for ($x .. $y) { + $sum += $_ if /^(\d+)\1+$/; + } +} +say $sum;