📄 bpigeon.pl
字号:
/*-------------------------------------------------------------------------*/
/* Benchmark (Boolean) */
/* */
/* Name : bpigeon.pl */
/* Title : pigeon-hole problem */
/* Originated from: */
/* Adapted by : Daniel Diaz for CLP(FD) */
/* Date : January 1993 */
/* */
/* Put N pigeons in M pigeon-holes. Solution iff N<=M. */
/* The solution is a list [ [Pig11,...,Pig1m], ... ,[Pign1,...,Pignm] ] */
/* where Pigij = 1 if the pigeon i is in the pigeon-hole j */
/* */
/* Solution: */
/* N=2 M=3 [[0,0,1],[0,1,0]] */
/* [[0,0,1],[1,0,0]] */
/* [[0,1,0],[0,0,1]] */
/* [[0,1,0],[1,0,0]] */
/* [[1,0,0],[0,0,1]] */
/* [[1,0,0],[0,1,0]] */
/*-------------------------------------------------------------------------*/
:-write('you need array.pl (www.probp.com/libraryplus/array.pl) to run this program.'),nl.
top:-
N=4,
N=5,
(bpigeon(N,M,A),
write(A),nl,
fail
;
write('No more solutions'), nl).
go:-
statistics(runtime,_),
top,
statistics(runtime,[_,Y]),
write('time : '), write(Y), nl.
bpigeon(N,M,A):-
create_array(N,M,A),
for_each_line(A,fd_only_one),
for_each_column(A,fd_at_most_one),
!,
array_labeling(A).
:-load(array).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -