aboutsummaryrefslogtreecommitdiff
path: root/challenge-241/deadmarshal/pascal/ch1.pas
blob: d3b3b537612c5aa8bd26f2b4437ac0c195026ae7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
program Ch1;

{$mode objfpc}
uses
  SysUtils,Types;

var
  A1,A2:TIntegerDynArray;
  
function ArithmeticTriplets(var Arr:TIntegerDynArray;
			    Diff:Integer):Integer;
var I,J,K:Integer;
begin
  Result := 0;
  for I := Low(Arr) to High(Arr) do
    for J := I+1 to High(Arr) do
      for K := J+1 to High(Arr) do
	if (Arr[J] - Arr[I] = Diff) and (Arr[K] - Arr[J] = Diff) then
	  Inc(Result);
end;

begin
  A1 := [0,1,4,6,7,10];
  A2 := [4,5,6,7,8,9];
  WriteLn(ArithmeticTriplets(A1,3));
  WriteLn(ArithmeticTriplets(A2,2));
end.