Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Department-numbers/Picat/department-numbers-1.picat
Normal file
22
Task/Department-numbers/Picat/department-numbers-1.picat
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import cp.
|
||||
|
||||
go ?=>
|
||||
N = 7,
|
||||
Sols = findall([P,S,F], department_numbers(N, P,S,F)),
|
||||
println(" P S F"),
|
||||
foreach([P,S,F] in Sols)
|
||||
printf("%2d %2d %2d\n",P,S,F)
|
||||
end,
|
||||
nl,
|
||||
printf("Number of solutions: %d\n", Sols.len),
|
||||
nl.
|
||||
go => true.
|
||||
|
||||
department_numbers(N, Police,Sanitation,Fire) =>
|
||||
Police :: 1..N,
|
||||
Sanitation :: 1..N,
|
||||
Fire :: 1..N,
|
||||
all_different([Police,Sanitation,Fire]),
|
||||
Police + Sanitation + Fire #= 12,
|
||||
Police mod 2 #= 0,
|
||||
solve([Police,Sanitation,Fire]).
|
||||
9
Task/Department-numbers/Picat/department-numbers-2.picat
Normal file
9
Task/Department-numbers/Picat/department-numbers-2.picat
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
go2 => department_numbers2(N) =>
|
||||
println(" P S F"),
|
||||
foreach(P in 1..N, P mod 2 == 0)
|
||||
foreach(S in 1..N, P != S)
|
||||
foreach(F in 1..N, F != P, F != S, P + S + F == 12)
|
||||
printf("%2d %2d %2d\n",P,S,F)
|
||||
end
|
||||
end
|
||||
end.
|
||||
9
Task/Department-numbers/Picat/department-numbers-3.picat
Normal file
9
Task/Department-numbers/Picat/department-numbers-3.picat
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import util.
|
||||
|
||||
department_numbers3(N) =>
|
||||
println("P S F"),
|
||||
L = [[P.to_string,S.to_string,F.to_string] : P in 1..N, P mod 2 == 0,
|
||||
S in 1..N, P != S,
|
||||
F in 1..N,
|
||||
F != P, F != S, P + S + F == 12],
|
||||
println(map(L,join).join("\n")).
|
||||
17
Task/Department-numbers/Picat/department-numbers-4.picat
Normal file
17
Task/Department-numbers/Picat/department-numbers-4.picat
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
go :-
|
||||
println("P F S"),
|
||||
assign(Police, Fire, Sanitation),
|
||||
printf("%w %w %w\n", Police, Fire, Sanitation),
|
||||
fail,
|
||||
nl.
|
||||
|
||||
dept(X) :- between(1, 7, X).
|
||||
|
||||
police(X) :- member(X, [2, 4, 6]).
|
||||
fire(X) :- dept(X).
|
||||
san(X) :- dept(X).
|
||||
|
||||
assign(A, B, C) :-
|
||||
police(A), fire(B), san(C),
|
||||
A != B, A != C, B != C,
|
||||
12 is A + B + C.
|
||||
Loading…
Add table
Add a link
Reference in a new issue