]> www.fi.muni.cz Git - aoc.git/blobdiff - 2019/16.pl
First half of Year 2019
[aoc.git] / 2019 / 16.pl
diff --git a/2019/16.pl b/2019/16.pl
new file mode 100755 (executable)
index 0000000..79a272d
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+use v5.16;
+
+chomp (my $data = <>);
+
+my @min;
+my $count = 25*6;
+my @p;
+for my $l ($data =~ /.{$count}/g) {
+       my @px = split //, $l;
+       my @p1;
+       for (@px) {
+               my $p0 = shift @p;
+               push @p1, !defined $p0 || $p0 == 2 ? $_ : $p0;
+       }
+       @p = @p1;
+       say "---";
+}
+
+my $i = 0;
+for (@p) {
+       print $_ ? '#' : ' ';
+       print "\n" if ++$i % 25 == 0;
+}