I need help with making this code more efficient because right now if I input a really big number for n, like 100, it takes beyond days to fully compute. Also, I must use recursion since that is part of my task. However, this may be the fastest way and there may be no more efficient solution, but I am not sure of that and was hoping someone could clarify.
code:
def hanoi(n, start, end):
if n==1:
print(str(start)+ " -> " + str(end))
else:
other = 6 - (start+end)
hanoi(n-1,start, other)
print(str(start)+ " -> " + str(end))
hanoi(n-1,other,end)
hanoi(3,1,3)
Here is a video for context about how the code works since it is quite abstract: https://www.youtube.com/watch?v=rf6uf3jNjbo
I considered monetization and tail recursion but I am confused on how approach implanting them here.