5 my $map; { local $/; $map = <>; }
7 my (@score, %seen, $round);
11 do { # rotate the map:
12 $map1 .= join('', reverse $map =~ /^./gm) . "\n"
13 } while $map =~ s/^.//gm;
15 1 while $map =~ s/O(\.+)/$1O/g; # move O's to the right
17 $score[$round] +=()= substr($map, pos($map)) =~ /\n/g
24 my $remains = (1000000000 - $round) % ($round - $seen{$map});
25 say $score[$seen{$map} + $remains];