From: Jan "Yenya" Kasprzak Date: Thu, 14 Dec 2023 17:20:14 +0000 (+0100) Subject: Day 14 part 2: minor cleanup X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=aoc.git;a=commitdiff_plain;h=ab399e76f3712a096b87cd5a019c6981c3fde323 Day 14 part 2: minor cleanup --- diff --git a/2023/28.pl b/2023/28.pl index 2d147f4..f0547dd 100755 --- a/2023/28.pl +++ b/2023/28.pl @@ -5,7 +5,8 @@ use v5.38; my $map; { local $/; $map = <>; } my (@score, %seen, $round); -while (++$round) { +while (!$seen{$map}) { + $seen{$map} = $round++; for (1 .. 4) { my $map1; do { # rotate the map: @@ -16,9 +17,6 @@ while (++$round) { } $score[$round] +=()= substr($map, pos($map)) =~ /\n/g while $map =~ /O/g; - - last if $seen{$map}; - $seen{$map} = $round; } my $remains = (1000000000 - $round) % ($round - $seen{$map});