Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Time-a-function/Picat/time-a-function.picat
Normal file
29
Task/Time-a-function/Picat/time-a-function.picat
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import cp.
|
||||
|
||||
go =>
|
||||
println("time/1 for 201 queens:"),
|
||||
time2(once(queens(201,_Q))),
|
||||
nl,
|
||||
|
||||
% time1b/1 is a used defined function (using statistics/2)
|
||||
Time = time1b($once(queens(28,Q2))),
|
||||
println(Q2),
|
||||
printf("28-queens took %dms\n", Time),
|
||||
nl.
|
||||
|
||||
% N-queens problem.
|
||||
% N: number of queens to place
|
||||
% Q: the solution
|
||||
queens(N, Q) =>
|
||||
Q=new_list(N),
|
||||
Q :: 1..N,
|
||||
all_different(Q),
|
||||
all_different([$Q[I]-I : I in 1..N]),
|
||||
all_different([$Q[I]+I : I in 1..N]),
|
||||
solve([ffd,split],Q).
|
||||
|
||||
% time1b/1 is a function that returns the time (ms)
|
||||
time1b(Goal) = T =>
|
||||
statistics(runtime, _),
|
||||
call(Goal),
|
||||
statistics(runtime, [_,T]).
|
||||
Loading…
Add table
Add a link
Reference in a new issue