]> www.fi.muni.cz Git - aoc.git/blobdiff - 2020/10.pl
Moved 2020 to a subdir
[aoc.git] / 2020 / 10.pl
diff --git a/2020/10.pl b/2020/10.pl
new file mode 100755 (executable)
index 0000000..2f7ade1
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my @seats;
+while (<>) {
+       chomp;
+       y/FBRL/0110/;
+       my $seat =  eval "0b$_";
+       $seats[$seat] = 1;
+}
+
+for (1 .. $#seats-1) {
+       print $_, "\n" if $seats[$_-1] && $seats[$_+1]
+               && !$seats[$_];
+}