fork download
  1. solve :-
  2. equal(_21, 4),
  3. equal(_14, 3),
  4. equal(_44, 1),
  5. straight([_10, _20, _30, _31]),
  6. line([_00, _01, _02, _03, _04]),
  7. line([_10, _11, _12, _13, _14]),
  8. line([_20, _21, _22, _23, _24]),
  9. line([_30, _31, _32, _33, _34]),
  10. line([_40, _41, _42, _43, _44]),
  11. line([_00, _10, _20, _30, _40]),
  12. line([_01, _11, _21, _31, _41]),
  13. line([_02, _12, _22, _32, _42]),
  14. line([_03, _13, _23, _33, _43]),
  15. line([_04, _14, _24, _34, _44]),
  16. greater_than(_01, _00),
  17. greater_than(_04, _03),
  18. odd(_02), odd(_11), odd(_12), odd(_22),
  19. even(_32), even(_42), even(_43),
  20. sum([_13, _23, _24], 9),
  21. product([_33, _34], 5),
  22. product([_40, _41], 15),
  23. 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]).
  24.  
  25. equal(X, X).
  26.  
  27. greater_than(X, Y) :- X > Y.
  28.  
  29. sum([X], X).
  30. sum([X | Xs], S) :- sum(Xs, S1), S =:= X + S1.
  31.  
  32. product([X], X).
  33. product([X | Xs], S) :- product(Xs, S1), S =:= X * S1.
  34.  
  35. line(L) :- permutation(L, [1, 2, 3, 4, 5]).
  36.  
  37. odd(X) :- 1 =:= X mod 2.
  38. even(X) :- 0 =:= X mod 2.
  39.  
  40. straight(L) :- permutation(L, [1, 2, 3, 4]).
  41. straight(L) :- permutation(L, [2, 3, 4, 5]).
  42.  
  43. permutation([], []).
  44. permutation(Xs, [X | Ys]) :- select(X, Xs, Zs), permutation(Zs, Ys).
  45.  
  46. :- solve.
Runtime error #stdin #stdout 15.99s 89216KB
stdin
Standard input is empty
stdout
Standard output is empty