[go: up one dir, main page]

Menu

[r19]: / XHANOI.MPL  Maximize  Restore  History

Download this file

21 lines (16 with data), 405 Bytes

//
// The Towers Of Hanoi
// BCPL
// Copyright (C) 1998 Amit Singh. All Rights Reserved.
// http://hanoi.kernelthread.com
//
// Tested under Martin Richards' BCPL over INTCODE compiler kit
//
// Converted to MPL by Derek John Evans
//

+libhdr

moveit(f,t) writef("move %n --> %n*n",f,t)

hanoi(n,t,f,u) n ? [
  hanoi(n-1,u,f,t); moveit(f,t); hanoi(n-1,t,u,f)
]

.() hanoi(5, 3, 1, 2)