From c7b8b6a8c8cd0426477c1d9c6a033599a4cd91b9 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Fri, 8 Dec 2023 10:35:08 -0500 Subject: [PATCH] prettier --- 2023/08/Part1.pm | 20 +++++++++++--------- 2023/08/Part2.pm | 1 - 2023/08/benchmark.pl | 4 ++-- 2023/08/part1.t | 21 ++++++++++----------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/2023/08/Part1.pm b/2023/08/Part1.pm index 2b58001..6b9823b 100644 --- a/2023/08/Part1.pm +++ b/2023/08/Part1.pm @@ -4,36 +4,38 @@ package Part1; use List::AllUtils qw/ /; -sub parse_input($input) { +sub parse_input ($input) { my ( $directions, undef, @nodes ) = split "\n", $input; $directions = [ split "", $directions =~ s/R/1/gr =~ s/L/0/gr ]; my %nodes; - for(@nodes) { + for (@nodes) { my @n = /([A-Z]+)/g; $nodes{ shift @n } = \@n; } return { directions => $directions, - nodes => \%nodes }; + nodes => \%nodes + }; } sub solution_1 ($input) { - my $p = parse_input($input); + my $p = parse_input($input); my @directions = $p->{directions}->@*; - my %nodes = $p->{nodes}->%*; + my %nodes = $p->{nodes}->%*; - my $visited = 0; + my $visited = 0; my $next_index = 0; - my $current = 'AAA'; + my $current = 'AAA'; - while( $current ne 'ZZZ') { + while ( $current ne 'ZZZ' ) { $visited++; - $current = $nodes{$current}->[ $directions[$next_index++ % @directions ] ]; + $current = + $nodes{$current}->[ $directions[ $next_index++ % @directions ] ]; } return $visited; diff --git a/2023/08/Part2.pm b/2023/08/Part2.pm index c907947..6e5705f 100644 --- a/2023/08/Part2.pm +++ b/2023/08/Part2.pm @@ -6,7 +6,6 @@ use Part1; use List::AllUtils qw/ /; - sub solution_2 ($input) { ...; } diff --git a/2023/08/benchmark.pl b/2023/08/benchmark.pl index 36ab17c..0d7280d 100644 --- a/2023/08/benchmark.pl +++ b/2023/08/benchmark.pl @@ -9,8 +9,8 @@ use File::Serialize; use Part1; use Part2; -my $day = path('.')->absolute->basename =~ s/^0//r; -my $year = path('.')->absolute->parent->basename; +my $day = path('.')->absolute->basename =~ s/^0//r; +my $year = path('.')->absolute->parent->basename; my $solutions = deserialize_file('solutions.yml'); my @parts = ( diff --git a/2023/08/part1.t b/2023/08/part1.t index 4168282..8661603 100644 --- a/2023/08/part1.t +++ b/2023/08/part1.t @@ -7,19 +7,20 @@ use File::Serialize; use Part1; -my $input = path('input')->slurp; -my $example = path('example')->slurp; +my $input = path('input')->slurp; +my $example = path('example')->slurp; my %solutions = deserialize_file('solutions.yml')->%*; my $parsed = Part1::parse_input($example); -use DDP; p $parsed; +use DDP; +p $parsed; -is $parsed->{directions} => [1,0]; -is $parsed->{nodes}{AAA} => [ qw/ BBB CCC /]; +is $parsed->{directions} => [ 1, 0 ]; +is $parsed->{nodes}{AAA} => [qw/ BBB CCC /]; - is Part1::solution_1($example) => 2; - is Part1::solution_1(<<'END') => 6; +is Part1::solution_1($example) => 2; +is Part1::solution_1(<<'END') => 6; LLR AAA = (BBB, BBB) @@ -27,11 +28,9 @@ BBB = (AAA, ZZZ) ZZZ = (ZZZ, ZZZ) END - SKIP: { - # skip "not there yet" if $solutions{1} eq 'TODO'; +SKIP: { + # skip "not there yet" if $solutions{1} eq 'TODO'; is Part1::solution_1($input) => $solutions{1}; } - - done_testing;