Решение 1
the_same(A-B-C-D, E-F-G-H) :-
sort([A, B, C, D], Res),
sort([E, F, G, H], Res).
has(Squares, Sq) :-
member(S, Squares),
the_same(S, Sq).
wo_dublicates([], []).
wo_dublicates([H | T], Res) :-
(has(T, H)
->
wo_dublicates(T, Res)
;
Res = [H | L],
wo_dublicates(T, L)).
24 ?- L = [a-b-d-c, a-c-d-b, b-a-c-d, b-d-c-a, c-a-b-d, c-d-b-a, d-b-a-c, d-c-a-b], wo_dublicates(L, R).
L = [a-b-d-c, a-c-d-b, b-a-c-d, b-d-c-a, c-a-b-d, c-d-b-a, ... -... -a-c, ... -... -b],
R = [d-c-a-b] ;
No
Решение 2
point(a,1,1).
point(b,1,5).
point(c,5,1).
point(d,5,5).
point(e,1,3).
main(L):-
findall(A-B-C-D,is_rect(A,B,C,D),L).
is_rect(A,B,C,D):-
point(A,X1,Y1),
point(B,X2,Y2),
point(C,X3,Y3),
point(D,X4,Y4),
A\=B,
B\=C,
C\=D,
A\=C,
A\=D,
B\=D,
St1 is sqrt(((X1-X2)*(X1-X2))+((Y1-Y2)*(Y1-Y2))),
St2 is sqrt(((X1-X4)*(X1-X4))+((Y1-Y4)*(Y1-Y4))),
St3 is sqrt(((X3-X2)*(X3-X2))+((Y3-Y2)*(Y3-Y2))),
St4 is sqrt(((X3-X4)*(X3-X4))+((Y3-Y4)*(Y3-Y4))),
Diag is sqrt(((X1-X3)*(X1-X3))+((Y1-Y3)*(Y1-Y3))),
Diag2 is sqrt(((X2-X4)*(X2-X4))+((Y2-Y4)*(Y2-Y4))),
abs(St1-St2)<0.0001,
abs(St2-St3)<0.0001,
abs(St3-St4)<0.0001,
abs(Diag-Diag2)<0.0001.
|