]> www.fi.muni.cz Git - aoc.git/blob - 2016/17.pl
Year 2016, days 1-10: so far pretty interesting
[aoc.git] / 2016 / 17.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use v5.30;
5
6 chomp (my $in = <>);
7 while ($in =~ /\((\d+)x(\d+)\)/g) {
8         my $p = pos($in) - length("($1x$2)");
9         my $str = substr($in, pos($in), $1);
10         my $repl = $str x $2;
11         say "repl=$repl";
12         substr($in, $p, length($str)+length("($1x$2)")) = $repl;
13         pos($in) = $p + length $repl;
14 }
15
16 say $in;
17 say length $in;