From 205c7164fa2bda84ab8af1414b20c1a722444470 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Wed, 25 Dec 2024 06:19:18 +0100 Subject: [PATCH] Day 25: shortened version --- 2024/49.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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; -- 2.43.5