The challenge is to find the bridges. The algorithm is based on recursion. Up to 10,000 items, everything works fine. But, if more, then the stack is full.

threading.stack_size(67108864) thread = threading.Thread(target=main) thread.start() 

I found this in the internet. It helped, but now it began to deduce some extra numbers, and figures that are generally beyond the limit of a possible answer.
If you simply increase the sys.setrecursionlimit(2**20) to max size does not help. But if you write 3 lines (which are thread), then the program at least works. But both correct answers and incorrect ones are displayed.

  • I came across a similar problem in the "toy" example. ru.stackoverflow.com/questions/770386/… - Vasyl Kolomiets
  • I’m wondering why, answers are taken that can’t be there at all. My answer is taken from the dictionary by key, so there’s not even such a key, and no error pops up on this issue - Vladislav Moskovkin
  • Oh - this is very interesting. But that is another question. Try to ask it in a separate question with code examples and incorrect output, if the structure of the program allows you to make a visible full example ... Or simulate the same error in the "toy" example. - Vasyl Kolomiets

1 answer 1

I came across a similar problem in the "toy" example. RecursionError: maximum recursion depth exceeded - how to overcome?
The solution was to change the algorithm and store your cache. In your case, everything is "worse." However, you can replace recursion with explicit work with your stack.
The problem is the stack size allocated by the OS for the application. So by default in Windows 2MB, and in Linux - 8MB.
Manually changing these parameters in Windows is troublesome. It is necessary to patch python.exe itself. I think it's easier to run under Linux ...