]> www.fi.muni.cz Git - aoc.git/commitdiff
Day 6: simple and fast
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Mon, 6 Dec 2021 05:08:08 +0000 (06:08 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Mon, 6 Dec 2021 05:08:08 +0000 (06:08 +0100)
11.pl [new file with mode: 0755]
12.pl [new file with mode: 0755]

diff --git a/11.pl b/11.pl
new file mode 100755 (executable)
index 0000000..18e31c7
--- /dev/null
+++ b/11.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+use v5.16;
+
+my @timers;
+
+for (split /,/, <>) {
+       $timers[$_]++;
+}
+
+my $days = 80;
+
+while ($days--) {
+       my $zero = shift @timers;
+       $timers[6]+=$zero;
+       $timers[8]+=$zero;
+}
+
+my $sum = 0;
+$sum += $_ for @timers;
+
+say $sum;
+
+       
+
diff --git a/12.pl b/12.pl
new file mode 100755 (executable)
index 0000000..990aac6
--- /dev/null
+++ b/12.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+use v5.16;
+
+my @timers;
+
+for (split /,/, <>) {
+       $timers[$_]++;
+}
+
+my $days = 256;
+
+while ($days--) {
+       my $zero = shift @timers;
+       $timers[6]+=$zero;
+       $timers[8]+=$zero;
+}
+
+my $sum = 0;
+$sum += $_ for @timers;
+
+say $sum;
+
+       
+