2025 Advent of Code Day 7 Part 2

Perl. Developed and tested with Perl 5.40.0. use v5 .40 ; no warnings q/recursion/ ; my @grid ; open DATA, q/data/ ; while ( <DATA> ){ chomp ; push @grid , [ split // , $_ ]; } close (DATA); my $count = 1 ; my $line = shift @grid ; my @beam = ( 1 , ( grep { $line -> [ $_ ] eq q/S/ } 0 .. @ { $line } - 1 )[ 0 ]); my $splits = advance( $beam [ 0 ], $beam [ 1 ], \ @grid ); $count = 1 + $splits ; say…