summaryrefslogtreecommitdiff
path: root/miralib/ex/hanoi.m
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-03-04 12:32:20 -0500
committerJakob Kaivo <jkk@ung.org>2022-03-04 12:32:20 -0500
commit55f277e77428d7423ae906a8e1f1324d35b07a7d (patch)
tree5c1c04703dff89c46b349025d2d3ec88ea9b3819 /miralib/ex/hanoi.m
import Miranda 2.066 from upstream
Diffstat (limited to 'miralib/ex/hanoi.m')
-rw-r--r--miralib/ex/hanoi.m11
1 files changed, 11 insertions, 0 deletions
diff --git a/miralib/ex/hanoi.m b/miralib/ex/hanoi.m
new file mode 100644
index 0000000..b927ca3
--- /dev/null
+++ b/miralib/ex/hanoi.m
@@ -0,0 +1,11 @@
+||This script generates a solution to the well known `Towers of Hanoi'
+||problem. To see the moves (for a game with 12 discs) say
+|| soln
+
+soln = title++hanoi 12 "A" "B" "C"
+title = "SOLUTION TO TOWERS OF HANOI WITH 8 DISCS\n\n"
+hanoi 0 a b c = []
+hanoi (n+1) a b c = hanoi n a c b
+ ++ move a b ++
+ hanoi n c b a
+move a b = "move the top disc from "++a++" to "++b++"\n"