]> www.fi.muni.cz Git - aoc.git/blob - 2018/04.pl
Day 25: examining the input
[aoc.git] / 2018 / 04.pl
1 #!/usr/bin/perl -w
2
3 use v5.30;
4 use strict;
5
6 my %seen;
7 while (<>) {
8         chomp;
9         for my $i (0 .. length($_) - 1) {
10                 my $x = $_;
11                 substr($x, $i, 1) = '_';
12                 $seen{$x}++;
13         }
14 }
15
16 for my $k (keys %seen) {
17         if ($seen{$k} == 2) {
18                 $k =~ s/_//;
19                 say $k;
20         }
21 }
22