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).