Skip to content

davidreghay/hanoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

hanoi

A little exercise born of my interest (and earlier struggles in understanding) in recursion. While recursion in general - and the famouse Tower of Hanoi problem in particular - is a concept commonly taught in early CS courses, I found that I (and many of my fellows) struggled with the concept early on and, after some time away from algorithm-heavy courses and no pressing need to use or study recursion, when returning to it for its own sake I struggled again. Therefore I decided to take on the challenge of designing a recursive algorithm for solving The Tower of Hanoi problem in general and then implementing it. The only implementation so far is in Java, since it's practically the "lingua franca" of developers these days. The current usage, therefore is (from the command line)...

  1. Compile the source: javac Hanoi.java
  2. Run! java Hanoi [-n DISKS]

Options

  • If given the optional [-n DISKS], Hanoi will run with a "Tower Height" of DISKS
  • If given the optional [-m DIRECTION], where DIRECTION is a 2 letter permutation of set S where S = {A, B, C}, Hanoi will run starting with the stack given by the first letter and ending on the second letter.

Example: java Hanoi -m CA -n 5

This is the quick and dirty implementation so far, but I'm planning on building off of it in the future. No license to speak of; this is code that anyone can rip off and do with as they please, without any need to credit me. It would be silly to do so, considering that this is a very well known exercise in programming, as previously noted. I should add, however, that my self-imposed challenge in writing was this was specifically not to cheat by looking up an answer, and to come to it myself through reasoning about it given my own understanding of the problem in particular, and recursion in general. Of course, I know this isn't much, and some might ask "why put unfinished work up for the public to see?" Well, the answer is, simply, I have a full-time job. I am attending school part-time. I have a whole life that you don't know about. But in the meantime I also want to continue refining my knowledge of algorithms and data structures and I figure that putting up my little exercises or projects up on GitHub and making them publicly available for use (or scrutiny) I might, hopefully, force myself to make enough time to devote to them and polish them, somewhat. Whew, what a mouthful! I hope that clears that up!

TLDR;

  • Recursion hard
  • Me solve Tower of Hanoi using recursion
  • Me want this be instructive for other programmers someday
  • Me want improve code more - more time!

Uh-bud-eh, bud-eh, bud-eh, that's all folks! Happy Coding!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages