home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / binprolog / binprolog_1 / !BinPro330_progs_han < prev    next >
Encoding:
Text File  |  1993-12-03  |  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.