]> www.fi.muni.cz Git - aoc.git/blob - 2022/35.pl
Day 18: interesting
[aoc.git] / 2022 / 35.pl
1 #!/usr/bin/perl -w
2
3 use v5.36;
4 use strict;
5
6 my @cubes = map { [ /(\d+)/g ] } <>;
7 my %cubes = map { join(',', @$_) => 1 } @cubes;
8
9 my $common;
10 for my $cube (@cubes) {
11         for my $axis (0 .. 2) {
12                 for my $add (-1, 1) {
13                         my @neigh = @$cube;
14                         $neigh[$axis] += $add;
15                         $common++ if $cubes{join(',', @neigh)};
16                 }
17         }
18 }
19 say 6*@cubes - $common;