aboutsummaryrefslogtreecommitdiff
path: root/challenge-215/deadmarshal/pascal/ch2.pas
blob: 300e72f649c7f5c30414a2fe896ea1cea5b12e31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
program Ch2;

{$mode objfpc}

uses
  SysUtils,Types;

function NumberPlacement(A:TIntegerDynArray;Count:Integer):Boolean;
var
  I,C:Integer;
begin
  C := 0;
  for I := 1 to High(A)-1 do
    if((A[I-1] = 0) and (A[I+1] = 0)) then Inc(C);
  Result := C >= Count;
end;

begin
  WriteLn(NumberPlacement([1,0,0,0,1],1));
  WriteLn(NumberPlacement([1,0,0,0,1],2));
  WriteLn(NumberPlacement([1,0,0,0,0,0,0,0,1],3));
end.