aboutsummaryrefslogtreecommitdiff
path: root/challenge-123/abigail/pascal/ch-2.p
blob: 3bd63c819a27ef5fcd282f4b63c280eb4406d56d (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
29
30
31
32
Program IsSquare;

(*                  *)
(* See ../README.md *)
(*                  *)

(*                                                        *)
(* Run as: fpc -och-2.out ch-2.p; ./ch-2.out < input-file *)
(*                                                        *)

function dist (x1, y1, x2, y2: integer): integer;
begin
    dist := (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)
end;

var
    x1, y1, x2, y2, x3, y3, x4, y4: integer;

begin
    while not eof () do begin
        readln (x1, y1, x2, y2, x3, y3, x4, y4);
        if (dist (x1, y1, x2, y2) = dist (x2, y2, x3, y3)) and
           (dist (x2, y2, x3, y3) = dist (x3, y3, x4, y4)) and
           (dist (x3, y3, x4, y4) = dist (x4, y4, x1, y1)) and
           (dist (x1, y1, x3, y3) = dist (x2, y2, x4, y4)) then begin
            writeln (1);
        end
        else begin
            writeln (0);
        end
    end
end.