From: Jan "Yenya" Kasprzak Date: Wed, 25 Dec 2024 05:19:18 +0000 (+0100) Subject: Day 25: shortened version X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;p=aoc.git Day 25: shortened version --- diff --git a/2024/49.pl b/2024/49.pl index ef8069a..54bdc46 100755 --- a/2024/49.pl +++ b/2024/49.pl @@ -3,17 +3,17 @@ use v5.40; $/ = "\n\n"; -my @keys = <>; - +my @keys; my $pairs; -for my ($i, $k1) (indexed @keys) { +while (<>) { K2: - for my $k2 (@keys[$i+1 .. $#keys]) { - for my $i (0 .. length $k1) { - next K2 if substr($k1, $i, 1) eq '#' - && substr($k2, $i, 1) eq '#'; + for my $k (@keys) { + for my $i (0 .. length) { + next K2 if substr($_, $i, 1) eq '#' + && substr($k, $i, 1) eq '#'; } $pairs++; } + push @keys, $_; } say $pairs;