title: Is there a way to program towers of hanoi without recursion/stacks?
body: <p>I recently wrote a program for solving towers of Hanoi using recursion. But is there a way to solve this puzzle without using stacks or recursion- preferably loops or something in that order. </p>
  
  <p>Here's the code I wrote using recursion:</p>
  
  <pre><code>static void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) 
      { 
          if (n == 1) 
          { 
              System.out.println("Move disk 1 from rod " + from_rod + " to rod " + to_rod); 
              return; 
          } 
          towerOfHanoi(n-1, from_rod, aux_rod, to_rod); 
          System.out.println("Move disk " + n + " from rod " + from_rod + " to rod " + to_rod); 
          towerOfHanoi(n-1, aux_rod, to_rod, from_rod); 
      } 
  </code></pre>
  
  <p>Thanks for any help in advance:)</p>