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:
}
$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});