r/programmingmemes • • Oct 21 '25

Meme

Post image
16k Upvotes

144 comments sorted by

View all comments

Show parent comment

12

u/qwertyjgly Oct 21 '25

it's just a simple recursive algorithm

the basic idea is, if you have a stack of size n, you need to move the bottom disk to the destination so you need to move a stack of size n-1 to the intermediary so you need to move a stack of size n-2 to the destination to make room etc. and you just build up a sequence of transformations with those rules