title: tower of hanoi - a tuple of moves
body: <pre><code>def hanoi(n,src,dsc,aux):
      if n == 1:
          print_move(src,dsc)
      else:
          hanoi(n-1,src,aux,dsc)
          print_move(src,dsc)
          hanoi(n-1,aux,dsc,src)
  
  def print_move(src,dsc):
      print("Move the top disk from",src,"to",dsc)
  </code></pre>
  
  <p>I wish to change the above tower of hanoi code to output a tuple of moves that when executed in sequence will move all the disk from source pole to destination pole via the auxiliary pole. A disk move is defined as a pair of two numbers: the source pole and the destination pole. For example, <code>(1, 3)</code> indicates the move of a disk from the first pole to the third. Hence, <code>hanoi(2,1,3,2)</code> will output <code>((1,2),(1,3),(2,3))</code></p>
  
  <p>My approach is to create a global variable called <code>tup</code>, an empty tuple. Then whenever a new tuple move is created, it will be added to the <code>tup</code>. My problem is I do not know when I should return the value of <code>tup</code> and where inside the <code>hanoi</code> function I can put the <code>return</code> line.</p>