2023-12-08 15:31:44 +00:00
|
|
|
use 5.38.0;
|
|
|
|
|
|
|
|
use Test2::V0;
|
|
|
|
|
|
|
|
use Path::Tiny;
|
2023-12-08 15:52:54 +00:00
|
|
|
use File::Serialize;
|
2023-12-08 15:31:44 +00:00
|
|
|
|
|
|
|
use Part2;
|
|
|
|
|
|
|
|
my $input = path('input')->slurp;
|
2023-12-09 16:47:37 +00:00
|
|
|
my $example = <<END;
|
2023-12-08 15:52:54 +00:00
|
|
|
LR
|
|
|
|
|
|
|
|
11A = (11B, XXX)
|
|
|
|
11B = (XXX, 11Z)
|
|
|
|
11Z = (11B, XXX)
|
|
|
|
22A = (22B, XXX)
|
|
|
|
22B = (22C, 22C)
|
|
|
|
22C = (22Z, 22Z)
|
|
|
|
22Z = (22B, 22B)
|
|
|
|
XXX = (XXX, XXX)
|
|
|
|
END
|
2023-12-09 16:47:37 +00:00
|
|
|
my %solutions = deserialize_file('solutions.yml')->%*;
|
|
|
|
|
|
|
|
|
|
|
|
my $parsed = Part1::parse_input($example);
|
2023-12-09 20:05:07 +00:00
|
|
|
#is [Part2::get_cycle('11A',$parsed->{directions},$parsed->{nodes})] => [1,2];
|
|
|
|
##use DDP; my @x = Part2::get_cycle('22A',$parsed->{directions},$parsed->{nodes});p @x;
|
|
|
|
#is [Part2::get_cycle('22A',$parsed->{directions},$parsed->{nodes})] => [1,2,3];
|
2023-12-09 16:47:37 +00:00
|
|
|
|
|
|
|
|
2023-12-09 20:31:25 +00:00
|
|
|
#is Part2::solution_2($example) => 6;
|
2023-12-09 16:47:37 +00:00
|
|
|
|
|
|
|
$parsed = Part1::parse_input($input);
|
|
|
|
|
|
|
|
# my @initial = grep { /A$/ } keys $parsed->{nodes}->%*;
|
|
|
|
# for (@initial ) {
|
|
|
|
# say join " ", Part2::get_cycle($_,$parsed->{directions},$parsed->{nodes});
|
|
|
|
# }
|
|
|
|
|
2023-12-08 15:52:54 +00:00
|
|
|
|
|
|
|
is Part2::solution_2($input) => $solutions{2};
|
2023-12-08 15:31:44 +00:00
|
|
|
|
|
|
|
done_testing;
|