a poor solution is to push multiples into an array, which fills the memory buffer and crashes. then, using a counter took me further, but that timed out after 12 seconds. finally, I tried a generator to economize memory usage. but the way a generator is structured, I was unable to pass n to solution() without hardcoding the n value.
Haha, ok. In my case I did the other kata first though :P
This one has performance tests, the other hasn't so it's no weird the solution of this one works in the other.
My same solution code (even the function names are the same) passes both this kata and the other kata: https://www.codewars.com/kata/multiples-of-3-or-5/
Added random tests, Node 8 support and allowed a 10e-9 margin of error for JS number issues.
Two years later that issue is known, still can't perform this kata in JS due to the last test :(
Is there a solution I didn't think about ?
I feel that it's too easy for 6 kyu
Has anyone solved this in Ruby? I keep coming back to this one and cannot get a solution that does not time out.
Ah, thanks. Despite trying a few different approaches I can't get the final calculation done in under 6 seconds. Some of the requirements of these problems are very opaque.
Your temporary list/object is too large.
My (Ruby) solution passes all test on this website & my own, yet get error message:
each': failed to allocate memory (NoMemoryError) from to_a' from solution' from block in
from wrap_error' from it'
from it' from
each': failed to allocate memory (NoMemoryError) from
I'm having that problem with ruby :(
Got it :)
No worries. By the way if you think that there's something wrong with a kata, mark your comment as "Issue". That way, your comment stands out and others can check whether the issue has been reported.