Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- my @Depths = <>;
- sub count_incs {
- my $window = shift @_;
- my $res = 0;
- for (my $i = 0; $i <= $#Depths - $window; $i++) {
- $res++ if ($Depths[$i + $window] > $Depths[$i]);
- }
- return ($res);
- }
- print "Part 1: ", &count_incs(1), "\n";
- print "Part 2: ", &count_incs(3), "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement