]> www.fi.muni.cz Git - aoc2020.git/blob - 45.pl
Task 9 Perl Golf-style
[aoc2020.git] / 45.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 my $rounds;
6 ($rounds, $_) = @ARGV;
7
8 while ($rounds--) {
9         my ($cur) = /\A(.)/;
10         do {
11                 $cur--;
12                 $cur = 9 if $cur == 0;
13         } while (/\A.{1,3}$cur/);
14         
15         s/\A(.)(...)(.*)$cur(.*)\z/$3$cur$2$4$1/;
16         print $_, "\n";
17 }
18
19 s/\A(.*)1(.*)\z/Result is $2$1\n/;
20 print;