day18.pl (567B) - raw
1 #!/usr/local/bin/perl 2 # day 2015-14 3 4 use strict; 5 use warnings; 6 use v5.32; 7 use lib '.'; 8 use Day18; 9 10 $| = 1; # flush output to STDOUT instead of buffering 11 12 @ARGV = "input" unless @ARGV; 13 chomp( my $input = do { local $/; <> } ); 14 15 my $STEPS = 100; 16 my $state_1 = init_lights( $input ); 17 my $state_2 = init_lights( $input ); 18 19 foreach ( 1 .. $STEPS ) 20 { 21 print "."; 22 $state_1 = flash_lights( $state_1, 1 ); 23 $state_2 = flash_lights( $state_2, 2 ); 24 } 25 print "\n"; 26 27 say "part 1: ", count_lights( $state_1 ); 28 say "part 2: ", count_lights( $state_2 );