]> www.fi.muni.cz Git - aoc.git/blobdiff - 2020/46re.pl
Mods from 2020
[aoc.git] / 2020 / 46re.pl
diff --git a/2020/46re.pl b/2020/46re.pl
new file mode 100644 (file)
index 0000000..442b5ff
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my $rounds;
+($rounds, $_) = @ARGV;
+$_ .= '3' x 10_000_000;
+
+while ($rounds--) {
+       my ($cur) = /\A(.)/;
+       do {
+               $cur--;
+               $cur = 9 if $cur == 0;
+       } while (/\A.{1,3}$cur/);
+       
+       s/\A(.)(...)(.*)$cur(.*)\z/$3$cur$2$4$1/;
+       # print $_, "\n";
+}
+
+s/\A(.*)1(.*)\z/Result is $2$1\n/;
+print;