]> www.fi.muni.cz Git - aoc.git/blob - 2019/11.pl
Day 25: examining the input
[aoc.git] / 2019 / 11.pl
1 #!/usr/bin/perl -w
2
3 use v5.16;
4 use List::Util qw(sum);
5
6 my %orb;
7 while (<>) {
8         chomp;
9         my @b = split /\)/;
10         $orb{$b[0]}{$b[1]} = 1;
11 }
12
13 my %orbs;
14 sub walk {
15         my ($b, $depth) = @_;
16         say "walking $b at $depth";
17         $orbs{$b} = $depth;
18         for my $x (keys %{ $orb{$b} }) {
19                 walk($x, $depth+1);     
20         }
21 }
22
23 walk('COM', 0);
24 say sum values %orbs;
25
26                 
27                 
28                 
29