aoc2015

Advent of Code 2015 solutions in Perl.
git clone git://git.samirparikh.com/aoc2015
Log | Files | Refs | README

commit 3a65d1e8f734425b294baa2b68278416afc9131d
parent a7b0e83527ac8385d2b548a4c51d65a3014dbcdf
Author: Samir Parikh <noreply@samirparikh.com>
Date:   Thu, 10 Nov 2022 23:49:18 +0000

clean up code but probasbly made it worse

Diffstat:
Mday18/Day18.pm | 18++++++++++--------
Mday18/day18.pl | 2+-
2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/day18/Day18.pm b/day18/Day18.pm @@ -69,14 +69,16 @@ sub flash_lights my $columns = scalar @{ $current_state->[ 0 ] }; foreach my $row ( 0 .. $rows - 2 ) { foreach my $col ( 0 .. $columns - 2 ) { - if ( ( $part == 2 ) && - ( $row == 0 && $col == 0 || - $row == 0 && $col == $columns - 2 || - $row == $rows - 2 && $col == 0 || - $row == $rows - 2 && $col == $columns - 2 ) ) { - $next_state[ $row ][ $col ] = '#'; - } else { - $next_state[ $row ][ $col ] = update_light( $row, $col, $current_state ); + if ( + ( $part == 2 ) && + ( $row == 0 && $col == 0 || + $row == 0 && $col == $columns - 2 || + $row == $rows - 2 && $col == 0 || + $row == $rows - 2 && $col == $columns - 2 ) + ) { + $next_state[ $row ][ $col ] = '#'; + } else { + $next_state[ $row ][ $col ] = update_light( $row, $col, $current_state ); } } push @{ $next_state[ $row ] } => '.'; # add trailing column back in diff --git a/day18/day18.pl b/day18/day18.pl @@ -6,12 +6,12 @@ use warnings; use v5.32; use lib '.'; use Day18; -use List::Util qw( max ); $| = 1; # flush output to STDOUT instead of buffering @ARGV = "input" unless @ARGV; chomp( my $input = do { local $/; <> } ); + my $STEPS = 100; my $state_1 = init_lights( $input ); my $state_2 = init_lights( $input );