Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I don't use JavaScript so I can't see your current solution, but if you are going through all numbers up to
n
and counting9
inside each one, it will be too slow (even with just this "simple loop" rather than an "infinite loop").Maybe the 50ms timing is for very small tests you have tried? Like with
n = 100
or something? In the full kata tests the inputn
goes to10**19
- try your function with this value on your PC tests if you want to see how fast it is.My function finish it in 50ms but on codewars i can't run tests , it's saying that the function times out. Can't because the code is fast with no infinite loops
This comment is hidden because it contains spoiler information about the solution
It is still unsoluble,...
You're awesome to be able to focus on that, but the sense of accomplishment that comes with a solution is unparalleled.
I don;t think there's too many test inputs. In Javascript, there's 100 random tests, and each can have numbers up to 100 digits long. My JavaScript solution passes the tests in ~1 second. I think tests are balanced quite well, you just need better algorithm.
Feel free to join Codewars Discord, you could get some help in the
#help-solve
channel!This comment is hidden because it contains spoiler information about the solution
Timeout error , my code is not long or hard to read , what happening ? fix this bug
Thank you very much, your answer helped me to understand
Also, important: you must always use the
return
instruction a the end of your function.print
has no effect (it just diplays stuff on the screen).Hi. Please post in English (you can help yourself with an online translator if you need).
You must not use
input
here, nor call the function in your code. Just complete the code of the function. The tests call your function with different argument and check it returns the right answer.Remove this:
Answered.
Можливо я не зрозумів суті, але чому мені видає помилку EOFError: EOF when reading a line
That was not hard
Loading more items...