solve :-
equal(_21, 4),
equal(_14, 3),
equal(_44, 1),
straight([_10, _20, _30, _31]),
line([_00, _01, _02, _03, _04]),
line([_10, _11, _12, _13, _14]),
line([_20, _21, _22, _23, _24]),
line([_30, _31, _32, _33, _34]),
line([_40, _41, _42, _43, _44]),
line([_00, _10, _20, _30, _40]),
line([_01, _11, _21, _31, _41]),
line([_02, _12, _22, _32, _42]),
line([_03, _13, _23, _33, _43]),
line([_04, _14, _24, _34, _44]),
greater_than(_01, _00),
greater_than(_04, _03),
odd(_02), odd(_11), odd(_12), odd(_22),
even(_32), even(_42), even(_43),
sum([_13, _23, _24], 9),
product([_33, _34], 5),
product([_40, _41], 15),
write([_00
, _01
, _02
, _03
, _04
, _10
, _11
, _12
, _13
, _14
, _20
, _21
, _22
, _23
, _24
, _30
, _31
, _32
, _33
, _34
, _40
, _41
, _42
, _43
, _44
]).
equal(X, X).
greater_than(X, Y) :- X > Y.
sum([X], X).
sum([X | Xs], S) :- sum(Xs, S1), S =:= X + S1.
product([X], X).
product([X | Xs], S) :- product(Xs, S1), S =:= X * S1.
line(L) :- permutation(L, [1, 2, 3, 4, 5]).
even
(X
) :- 0 =:= X
mod 2.
straight(L) :- permutation(L, [1, 2, 3, 4]).
straight(L) :- permutation(L, [2, 3, 4, 5]).
permutation([], []).
permutation(Xs, [X | Ys]) :- select(X, Xs, Zs), permutation(Zs, Ys).
:- solve.
c29sdmUgOi0KICBlcXVhbChfMjEsIDQpLAogIGVxdWFsKF8xNCwgMyksCiAgZXF1YWwoXzQ0LCAxKSwKICBzdHJhaWdodChbXzEwLCBfMjAsIF8zMCwgXzMxXSksCiAgbGluZShbXzAwLCBfMDEsIF8wMiwgXzAzLCBfMDRdKSwKICBsaW5lKFtfMTAsIF8xMSwgXzEyLCBfMTMsIF8xNF0pLAogIGxpbmUoW18yMCwgXzIxLCBfMjIsIF8yMywgXzI0XSksCiAgbGluZShbXzMwLCBfMzEsIF8zMiwgXzMzLCBfMzRdKSwKICBsaW5lKFtf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