CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
7
Task/Combinations/Prolog/combinations-1.pro
Normal file
7
Task/Combinations/Prolog/combinations-1.pro
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:- use_module(library(clpfd)).
|
||||
|
||||
comb_clpfd(L, M, N) :-
|
||||
length(L, M),
|
||||
L ins 1..N,
|
||||
chain(L, #<),
|
||||
label(L).
|
||||
12
Task/Combinations/Prolog/combinations-2.pro
Normal file
12
Task/Combinations/Prolog/combinations-2.pro
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
?- comb_clpfd(L, 3, 5), writeln(L), fail.
|
||||
[1,2,3]
|
||||
[1,2,4]
|
||||
[1,2,5]
|
||||
[1,3,4]
|
||||
[1,3,5]
|
||||
[1,4,5]
|
||||
[2,3,4]
|
||||
[2,3,5]
|
||||
[2,4,5]
|
||||
[3,4,5]
|
||||
false.
|
||||
10
Task/Combinations/Prolog/combinations-3.pro
Normal file
10
Task/Combinations/Prolog/combinations-3.pro
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
comb_Prolog(L, M, N) :-
|
||||
length(L, M),
|
||||
fill(L, 1, N).
|
||||
|
||||
fill([], _, _).
|
||||
|
||||
fill([H | T], Min, Max) :-
|
||||
between(Min, Max, H),
|
||||
H1 is H + 1,
|
||||
fill(T, H1, Max).
|
||||
3
Task/Combinations/Prolog/combinations-4.pro
Normal file
3
Task/Combinations/Prolog/combinations-4.pro
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
:- use_module(library(clpfd)).
|
||||
comb_lstcomp(N, M, V) :-
|
||||
V <- {L & length(L, N), L ins 1..M & all_distinct(L), chain(L, #<), label(L)}.
|
||||
Loading…
Add table
Add a link
Reference in a new issue