]> www.fi.muni.cz Git - aoc.git/blobdiff - 2016/17.pl
Year 2016, days 1-10: so far pretty interesting
[aoc.git] / 2016 / 17.pl
diff --git a/2016/17.pl b/2016/17.pl
new file mode 100755 (executable)
index 0000000..768cda1
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+
+use strict;
+use v5.30;
+
+chomp (my $in = <>);
+while ($in =~ /\((\d+)x(\d+)\)/g) {
+       my $p = pos($in) - length("($1x$2)");
+       my $str = substr($in, pos($in), $1);
+       my $repl = $str x $2;
+       say "repl=$repl";
+       substr($in, $p, length($str)+length("($1x$2)")) = $repl;
+       pos($in) = $p + length $repl;
+}
+
+say $in;
+say length $in;