home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / b / binprolog / !BinPro330 / progs / han < prev    next >
Encoding:
Text File  |  1993-12-04  |  269 b   |  15 lines

  1. /* Prolog version of hanoi benchmark */
  2.  
  3. go:-go(16).
  4.  
  5. time(T):-statistics(runtime,[T,_]).
  6.  
  7. go(N) :- time(T1),han(N,1,2,3),time(T2),T is T2-T1,write(T),nl.
  8.  
  9. han(N,_,_,_) :- N=<0,!.
  10. han(N,A,B,C) :- N>0,
  11.         N1 is N - 1,
  12.         han(N1,A,C,B),
  13.         han(N1,C,B,A).
  14.  
  15.