Advertisement
przemko

Więzy -- kwadrat

Jun 14th, 2017
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.67 KB | None | 0 0
  1. % kwadrat.pl
  2.  
  3. :- use_module(library(clpfd)).
  4.  
  5. main(Xs) :-
  6.         kwadraty(112,
  7.                  [50,42,37,35,33,29,27,25,24,19,18,17,16,15,11,9,8,7,6,4,2],
  8.                  Xs).
  9.  
  10. kwadraty(D, Ds, Xs) :-
  11.         length(Ds, N),
  12.         D1 is D-1,
  13.         length(Xs, N),
  14.         Xs ins 0..D1,
  15.         length(Ys, N),
  16.         Ys ins 1..D,
  17.         zadania(Xs, Ys, Ds, Zadania),
  18.         cumulative(Zadania, [limit(D)]),
  19.         % SICStus Prolog z opcją global(true) w cumulative/2 8500ms
  20.         labeling([ffc], Xs).
  21.  
  22. zadania([], [], [], []).
  23. zadania([X | L1], [Y | L2], [D | L3], [task(X, D, _, D, _) | L4]) :-
  24.         Y #= X + D,
  25.         zadania(L1, L2, L3, L4).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement