+ 2

How can I deal with exceeding the time limit?

I've been making some python code but every time I use a somewhat large number , make use of larger or recursive function , I get the message "Time limit exceeded" when I run my code . For example , in this code ,I get this message when I input more than 40: https://code.sololearn.com/cPh9Yx5mDxQd/#py .Is there any way of dealing with it or I should code somewhere else?

30th Dec 2018, 5:11 PM
dimitris9
5 odpowiedzi
0
Exceeding the time limit means the program you are using is doing more computations than expected. In other words, with your given looping, the acceptable is within a 1-2s time limit. I recommend trying to rewrite your code, however, I do not know any other line you could write to "cancel" the error.
30th Dec 2018, 5:25 PM
Matthew Grimalovsky
Matthew Grimalovsky - avatar
+ 4
Do you suggest I should download Python and write my code there?
30th Dec 2018, 8:39 PM
dimitris9
+ 2
Could you please recommend a platform which allows a longer (i.e. 1 minuta) time limit?
7th Jan 2019, 1:32 PM
Trafalgar Vanessa
Trafalgar Vanessa - avatar
+ 1
Using recursion is actually very tedious for the computer to handle, and the error is displayed when there is a stack, or memory, overflow.
30th Dec 2018, 5:35 PM
Matthew Grimalovsky
Matthew Grimalovsky - avatar
+ 1
Here, I used the standard dictionary method: https://code.sololearn.com/ccVJqB4IWXem/#py
30th Dec 2018, 5:38 PM
Matthew Grimalovsky
Matthew Grimalovsky - avatar