srednee len LEN sum SUM is SUM LEN sum sum sum S1 is S1 len len len N1

 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
srednee(L, Z) :-
len(L, LEN),
sum(L, SUM),
Z is SUM/LEN.
sum([], 0).
sum([X | T], S) :-
sum(T, S1),
S is S1 + X.
len([], 0).
len([_ | T], N) :-
len(T, N1),
N is N1 + 1.
puzzle(L) :-
permutation(L,
[sov, sov, chesh, bolg]),
L = [Mitya, Tolya, Petya, Sasha],
Mitya \== Tolya,
Mitya \== Sasha,
Petya \== Sasha,
Petya \== Mitya,
Tolya \== Sasha,
Mitya \== 'bolg'.
podobie(X1, Y1, X2, Y2, X3, Y3, X4, Y4, X5, Y5, X6, Y6) :-
podobni(X1, Y1, X2, Y2, X3, Y3, X4, Y4, X5, Y5, X6, Y6);
podobni(X1, Y1, X2, Y2, X3, Y3, X5, Y5, X6, Y6, X4, Y4);
podobni(X1, Y1, X2, Y2, X3, Y3, X6, Y6, X4, Y4, X5, Y5).
podobni(X1, Y1, X2, Y2, X3, Y3, X4, Y4, X5, Y5, X6, Y6) :-
rasstoyanie(X1, Y1, X2, Y2, R1),
rasstoyanie(X2, Y2, X3, Y3, R2),
rasstoyanie(X3, Y3, X1, Y1, R3),
rasstoyanie(X4, Y4, X5, Y5, R4),
rasstoyanie(X5, Y5, X6, Y6, R5),
rasstoyanie(X6, Y6, X4, Y4, R6),
(R1==8),
(R3==16),
(R4==8),
(R6==16),
((R1*R6)==(R3*R4)).
ravni(V1,V2,V3,V4) :-
(V1*V4==V2*V3).
true(V1,V2,V3,V4) :-
(5==5).
rasstoyanie(X1, Y1, X2, Y2, R) :-
R is ((X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1)).
podobni(1,1,3,3,1,5,5,1,7,3,5,5).