kernelthread.com

YACAS

The Towers of Hanoi as a YACAS program.

YACAS (Yet Another Computer Algebra System) is a general purpose Computer Algebra System that has been designed to be easy to use. It is a program for symbolic manipulation of mathematical expressions, with its own program language designed for symbolic as well as arbitrary precision numerical computations.

More information on YACAS can be found on the YACAS website.

/// The Towers Of Hanoi /// Yacas Implementation /// Copyright (C) 2002 Amit Singh. All Rights Reserved. /// http://hanoi.kernelthread.com /// /// Last tested under Yacas 1.0.54 /// /// Usage: At the yacas input prompt, type the following commands: /// /// Use("hanoi.ys") /// hanoi(3) /// /// YACAS (Yet Another Computer Algebra System) /// http://yacas.sourceforge.net /// 10 # H(_n, _f, _u, _t) _ (n = 1) <-- Echo(f, " --> ", t); 20 # H(n_IsInteger, f_IsInteger, u_IsInteger, t_IsInteger) _ (n > 1) <-- [ H(n - 1, f, t, u); Echo(f, " --> ", t); H(n - 1, u, f, t); ]; 10 # hanoi(_n) _ (n < 1) <-- [ Echo("the number of disks must be a positive integer"); False; ]; 20 # hanoi(_n) _ (n > 10) <-- [ Echo("the number of disks must be less than or equal to 10"); False; ]; 30 # hanoi(n_IsInteger) <-- H(n, 1, 2, 3);

Download

hanoi.ys