Python ‚time limit exceeded’ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python ‚time limit exceeded’

On what does the message ‘time limit exceeded’ depend in Python? Is this because of the playground, the used device or the limitation due to encapsulated for-loops? https://code.sololearn.com/cIo906mB32Q8/?ref=app

25th Apr 2019, 8:02 AM
M3di0h0mbr3
M3di0h0mbr3 - avatar
6 Answers
+ 3
The innermost loop will be executed 26^5 = ca. 12 million times. If every print() takes 1 ms, the whole code will need > 3 hrs to run.
25th Apr 2019, 8:24 AM
Anna
Anna - avatar
+ 2
Are you sure? Maybe if you remove the "print()". I ran your code on a PC and interrupted it after 60 seconds. The last string that was displayed was "Aayaq". Meaning there were still more than 25^2 = 625 times of all possible combinations left. 1 min * 625 > 10 hrs total execution time. /Edit: If I remove print(), it executes in ~ 4 seconds. Millions of prints() will definitely not be done in under one minute though.
25th Apr 2019, 10:09 AM
Anna
Anna - avatar
+ 1
oh. each program other than web run in SoloLearn server. to prevent heavy burden on the server because many people use them at same time. each running program has limited time to execute. tldr, your program take more time to finish than SoloLearn server limitation
25th Apr 2019, 8:07 AM
Taste
Taste - avatar
+ 1
It's a sololearn time limitation. I tried your program on https://repl.it/languages/python3 and it works as expected.
25th Apr 2019, 8:11 AM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
0
Executed in the real world the program went through in less then a minute.
25th Apr 2019, 9:59 AM
M3di0h0mbr3
M3di0h0mbr3 - avatar
0
Okay, I exchanged the print with a command to write in a file.
25th Apr 2019, 10:13 AM
M3di0h0mbr3
M3di0h0mbr3 - avatar