https://www.fi.muni.cz/~kas/git
/
aoc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
72dc84c
)
Day 25: shortened version
master
author
Jan "Yenya" Kasprzak
<kas@fi.muni.cz>
Wed, 25 Dec 2024 05:19:18 +0000
(06:19 +0100)
committer
Jan "Yenya" Kasprzak
<kas@fi.muni.cz>
Wed, 25 Dec 2024 05:19:18 +0000
(06:19 +0100)
2024/49.pl
patch
|
blob
|
history
diff --git
a/2024/49.pl
b/2024/49.pl
index ef8069ad0637de966be7ba5181f7d35d419a7461..54bdc463a312586a089baf720eae92481811ee8c 100755
(executable)
--- 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 $k
2 (@keys[$i+1 .. $#keys]
) {
- for my $i (0 .. length
$k1
) {
- next K2 if substr($
k1
, $i, 1) eq '#'
- && substr($k
2
, $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;