aboutsummaryrefslogtreecommitdiff
path: root/challenge-215/deadmarshal/perl/ch-2.pl
blob: 4cb1b78063c77cda0f1443259c4e7d49e51fa879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env perl
use strict;
use warnings;
use List::MoreUtils qw(slideatatime);

sub number_placement{
  my ($arr,$count) = @_;
  my $it = slideatatime 1,3,@$arr;
  my $c = 0;
  while(my @vals = $it->()){
    $c++ if $vals[0] == 0 && $vals[-1] == 0;
  }
  $c >= $count;
}

printf "%d\n", number_placement([1,0,0,0,1],1);
printf "%d\n", number_placement([1,0,0,0,1],2);
printf "%d\n", number_placement([1,0,0,0,0,0,0,0,1],3);