fork download
  1. def hanoi(disc, ori, dest, aux):
  2. if disc == 1:
  3. print('Move disc {} from tower {} to the tower {}'.format(disc, ori, dest))
  4. return
  5.  
  6. hanoi(disc - 1, ori, aux, dest)
  7. print('Move disc {} from tower {} to the tower {}'.format(disc, ori, dest))
  8. hanoi(disc - 1, aux, dest, ori)
  9.  
  10. hanoi(1000, 'A', 'B', 'C')
Runtime error #stdin #stdout #stderr 0.13s 24288KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 10, in <module>
  File "./prog.py", line 6, in hanoi
  File "./prog.py", line 6, in hanoi
  File "./prog.py", line 6, in hanoi
  [Previous line repeated 995 more times]
  File "./prog.py", line 2, in hanoi
RecursionError: maximum recursion depth exceeded in comparison