Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

TiredOfLife's blog

By TiredOfLife, history, 5 years ago, In English

Today I was making an automated program to solve 8 Puzzle and when I am running the same logic in c++ it is working fine but in python it is going to near about 6000-6500 recursions and the recursion is not even working properly and I have no idea why ? Please help !

Note
Python Code
C++ Code
Note2
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Use Bootstrap recursion with PyPy2 in order to avoid recursion problems in Python. You can have at the # Pajenegod's Solution of recursion problems, he generally uses Bootstrap recursion Have a look at this link... https://github.com/cheran-senthil/PyRival/blob/master/pyrival/misc/bootstrap.py

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    But I think python should also do the job and I want to know why these errors happen in python .
    I used recursion in python for the first time in life .

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      yeah..it can work with Python also but if you wanna speed up your program then you must use PyPy2. Generally, Python has inbuilt very small recursion limit (10**3) so, to increase it we generally write sys.setrecursionlimit(10**7)

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I have increased it .
        But it is still running for only near about 6500 .