]> www.fi.muni.cz Git - aoc.git/blob - 2017/13.pl
Day 25: examining the input
[aoc.git] / 2017 / 13.pl
1 #!/usr/bin/perl
2
3 use v5.30;
4 use strict;
5
6 my %all;
7 my %below;
8 my %top;
9
10 while (<>) {
11         my ($name, $num, $rest) = /^(\w+) \((\d+)\)(.*)/;
12         $all{$name} = $num;
13         next if !length $rest;
14         for my $t ($rest =~ /(\w+)/g) {
15                 $below{$t} = $name;
16                 $top{$t} = 1;
17         }
18 }
19
20 for my $node (keys %all) {
21         say $node if !$top{$node};
22 }
23
24
25