brpapa / recursion-tree-visualizer

🌳 Input the source code of any recursive function in javascript, python or golang and visualize its recursion tree
https://recursion.vercel.app
MIT License
471 stars 64 forks source link

Feature Request Slow it down! #4

Open ughstudios opened 3 years ago

ughstudios commented 3 years ago

https://recursion.now.sh/

I found this on your website. It's a great little tool for visual learners. However, I was curious if there is a way to slow down the visualization or maybe pause it?

brpapa commented 3 years ago

At the moment, you can only stop the animation by clicking on the top bar, and then move forward or backward step by step by clicking the arrows.

But I am thinking of implementing a customized option in which the user can define your own pace. Thanks for the request, by the way!

prashul commented 3 years ago

Hello @brpapa ,

def fn(s:str,i,j,k):
    if i >= len(s):
        if k >= 2:
            return True
        return False
    currNo = 0
    for i in range(i,len(s)):
        currNo = currNo*10 + int(s[i])
        if( j == -1 or (j-currNo) == 1 ):
            if fn(s,i+1,currNo,count+1):
                return True
    return False

Getting error with this code, Can you pls identify what is going wrong , runs fine in IDE ?

fn('1234',0,-1,0)

Error response - Your code outputs the following File "", line 19, in _fn: ''

brpapa commented 3 years ago

Hi @prashul,

I improved the error messages. If you run it again you will see that the count var is not defined.