How can I minimize the execution time? | Sololearn: Learn to code for FREE!


How can I minimize the execution time?

The task description provided in the code. Thank you.

6/15/2020 1:20:21 AM


6 Answers

New Answer


Robin, no range limit.


Thank you, Robin! I tested both of your solutions (you’re amazing!), everything works! But looks like I need to include all of them in the code, depending on the number range. Thank you again!


Thank you, Robin, so much! Gonna to implement it ASAP.


Actually, I figured out, that odd numbers like 9, for example, are alredy have everything in themselves: 9 = 4 + 5, where 9 + 4 ** 2 = 5 ** 2. You can easily check all other odd numbers in range of 100 at least. But in a matter to find the smallest perfect square, we faced again to the iteration which takes time.


At least it should work for the prime numbers, as you mentioned above, so we don’t have to iterate through in this case. Very interesting task, are you agree? Actually, the task is one of the Katas in codewars. You can try to implement the solution by yourself, if you intrested in. But definitely, I would prefer that you will not share the successfully executed code with me. I gonna handle with it by myself. I mean, with your previous hints, for shure! which I got enogh and really appreciate your help)) Thank you again, Robin. Good luck!


Oh, yhea, Robin)) It still follows me as well))