Блог пользователя TiredOfLife

Автор TiredOfLife, история, 5 лет назад, По-английски

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
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
5 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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)