+ 1

Program keeps returning Time Limit Exceeded

Hi! I was trying to do the Crazy Number Challenge, and the code I created was too bulky and didn't manage memory well. I tested out most of the individual parts, but the code is too slow. I keep on getting " Time Limit Exceeded" May you help me make it more efficient? https://code.sololearn.com/cCJ9CpYvta70

11th Dec 2017, 3:10 AM
Nathen Te
Nathen Te - avatar
5 Respuestas
0
This is my answer to the challenge: https://code.sololearn.com/cHKplv3YJ0bI/?ref=app I coded in C++ so you could read and understand it.
11th Dec 2017, 5:13 AM
John Wells
John Wells - avatar
+ 6
Try it on Code::Blocks; SoloLearn's Code Playground really doesn't like long codes (it might not even be due to time problems at all!) Some work fine on Code:: Blocks but not Code Playground, for some mysterious reason nobody comprehends. This also extends to all languages. Best of luck! 😉
11th Dec 2017, 3:23 AM
blackcat1111
blackcat1111 - avatar
+ 2
Thank you for the advice, blackcat! I'll try it out
11th Dec 2017, 3:26 AM
Nathen Te
Nathen Te - avatar
+ 1
Thank you for this. I think a major difference is that I rely a LOT on for loops and yours doesn't do as many loops with so many specifications. I'll try making that simpler. Thank you!
11th Dec 2017, 11:35 AM
Nathen Te
Nathen Te - avatar
- 1
Normally, I would have coded in Java as I'm still learning the ins and outs. But, looking at your code to optimize it, I decided it would be easier to code my own.
11th Dec 2017, 3:05 PM
John Wells
John Wells - avatar