Go Recursion – The Tower Of Hanoi

If you want to know the logic of the tower of Hanoi, please refer to this article Python recursion – The Tower of Hanoi. They are exactly the same, just using different language.

Continue reading


Python and simple recursion

This afternoon my husband and I talked about recursion, and we decided to write some recursion functions with different languages. He uses JavaScript, and I use Python.

Here is the simple question: Please use recursion to revert 12345 to 54321

def reverse(val, new_val):
    if val == '':
        reverse(val[:-1], new_val + val[-1:])

if __name__ == '__main__':
    reverse(raw_input('Please provide any number: '), '')

Continue reading