]> www.fi.muni.cz Git - aoc.git/blob - 2018/45.pl
Day 25: examining the input
[aoc.git] / 2018 / 45.pl
1 #!/usr/bin/perl -w
2
3 use v5.34;
4 use strict;
5
6 my @bots;
7 my $highest;
8 while (<>) {
9         my ($x, $y, $z, $r) = /(-?\d+)/g;
10         push @bots, [$x, $y, $z, $r];
11         if (!$highest || $highest->[3] < $r) {
12                 $highest = [$x, $y, $z, $r];
13         }
14 }
15
16 my ($x, $y, $z, $r) = @$highest;
17
18 my $in_range;
19 for my $bot (@bots) {
20         $in_range++ if
21                 abs($bot->[0] - $x)
22                 + abs($bot->[1] - $y)
23                 + abs($bot->[2] - $z) <= $r;
24 }
25
26 say $in_range;
27         
28