This commit is contained in:
Yanick Champoux 2023-12-08 10:35:08 -05:00
parent b1cf1719a3
commit c7b8b6a8c8
4 changed files with 23 additions and 23 deletions

View File

@ -18,7 +18,8 @@ sub parse_input($input) {
return { return {
directions => $directions, directions => $directions,
nodes => \%nodes }; nodes => \%nodes
};
} }
sub solution_1 ($input) { sub solution_1 ($input) {
@ -33,7 +34,8 @@ sub solution_1 ($input) {
while ( $current ne 'ZZZ' ) { while ( $current ne 'ZZZ' ) {
$visited++; $visited++;
$current = $nodes{$current}->[ $directions[$next_index++ % @directions ] ]; $current =
$nodes{$current}->[ $directions[ $next_index++ % @directions ] ];
} }
return $visited; return $visited;

View File

@ -6,7 +6,6 @@ use Part1;
use List::AllUtils qw/ /; use List::AllUtils qw/ /;
sub solution_2 ($input) { sub solution_2 ($input) {
...; ...;
} }

View File

@ -13,7 +13,8 @@ my %solutions = deserialize_file('solutions.yml')->%*;
my $parsed = Part1::parse_input($example); my $parsed = Part1::parse_input($example);
use DDP; p $parsed; use DDP;
p $parsed;
is $parsed->{directions} => [ 1, 0 ]; is $parsed->{directions} => [ 1, 0 ];
is $parsed->{nodes}{AAA} => [qw/ BBB CCC /]; is $parsed->{nodes}{AAA} => [qw/ BBB CCC /];
@ -32,6 +33,4 @@ END
is Part1::solution_1($input) => $solutions{1}; is Part1::solution_1($input) => $solutions{1};
} }
done_testing; done_testing;