Skip to content

Instantly share code, notes, and snippets.

@Wilfred
Created May 8, 2009 21:37
Show Gist options
  • Save Wilfred/109025 to your computer and use it in GitHub Desktop.
Save Wilfred/109025 to your computer and use it in GitHub Desktop.
(* write an ML function such that Move(3,"A","B","C") solves the hanoi puzzle*)
load "Int";
fun Move(1,start,other,finish) = ["move 1 from " ^ start ^ " to " ^ finish]
| Move (x,start,other,finish) =
Move(x-1,start,finish,other)@
["move " ^ (Int.toString x) ^ " from " ^ start ^ " to " ^ finish]@
Move(x-1,other,start,finish);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment