Tower of Hanoi on a TI-84 Plus CE-T

Posted by on January 9, 2025

The Tower of Hanoi is something I “have to” do on any calculator I encounter, but using Python feels almost like cheating, it is just too easy. Unfortunately there is little else of interest for this task on this calculator.

def hanoi(n,a,b,c):
  if n==1:
    print(a," >> ",b)
  else:
   hanoi(n-1,a,c,b)
   hanoi(1,a,b,c)
   hanoi(n-1,c,b,a)

hanoi(3,1,2,3)

To fit it on one screen we are just moving 3 disks from peg 1 to peg 2, using peg 3 as a helper:

Comments are closed.