aoc2015

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

commit a609bf1a74c59bb5b65d9fa9b37a1958d8961d6a
parent 477ebae20e16f9e83a0eb5bece67257c5e5aacf6
Author: Samir Parikh <noreply@samirparikh.com>
Date:   Thu, 10 Nov 2022 23:44:12 +0000

clean up code

Diffstat:
Mday18/Day18.pm | 5-----
Mday18/day18.pl | 4++--
2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/day18/Day18.pm b/day18/Day18.pm @@ -49,13 +49,8 @@ sub update_light foreach my $neighbor ( @neighbors ) { my $neighbor_row = $row + $neighbor->[0]; my $neighbor_col = $col + $neighbor->[1]; -# say "------------"; -# say "row $row + neighbor_row $neighbor->[0] = $neighbor_row"; -# say "col $col + neighbor_col $neighbor->[1] = $neighbor_col"; -# say "light is <$lights[ $neighbor_row ][ $neighbor_col ]>"; $neighbors_on++ if ( $lights[ $neighbor_row ][ $neighbor_col ] eq '#' ); } -# say "light $row, $col has $neighbors_on neighbors that are on"; if ( $lights[ $row ][ $col ] eq '#' ) { return ( $neighbors_on == 2 || $neighbors_on == 3 ) ? '#' : '.'; } else { diff --git a/day18/day18.pl b/day18/day18.pl @@ -8,7 +8,7 @@ use lib '.'; use Day18; use List::Util qw( max ); -$| = 1; +$| = 1; # flush output to STDOUT instead of buffering @ARGV = "input" unless @ARGV; chomp( my $input = do { local $/; <> } ); @@ -23,6 +23,6 @@ foreach ( 1 .. $STEPS ) $state_2 = flash_lights( $state_2, 2 ); } print "\n"; -#display_lights($state_2); + say "part 1: ", count_lights( $state_1 ); say "part 2: ", count_lights( $state_2 );