Yeah, you write this when you don't know that to find all the factors of a number it is enough to iterate to sqrt(n), not necessarily to n, and that this gives acceptable performance for the kata.
Once again Ruby bahaves unlike other languages in a very annoying way. Why? Why I can't just convert booleans to 0 and 1 with .to_i method for instance? There is no reason I cannot do that by default
That's brilliant!
Nice solution. By the way, I have a question - is this solution O(n^2) (one n from loop and another from 'in' operator), or it is more efficient?
Brillaint! The logic of my solution is the same. But this solution is much shorter and also two times faster!
Yeah, you write this when you don't know that to find all the factors of a number it is enough to iterate to sqrt(n), not necessarily to n, and that this gives acceptable performance for the kata.
So, this guy just hacked the testing sytem with the cache. Well, that is cool, in some sense
Brilliant!
This is the only right way to solve the problem. Nice job!
Solution of O(nlogn) complexity for O(n) problem, though
Once again Ruby bahaves unlike other languages in a very annoying way. Why? Why I can't just convert booleans to 0 and 1 with .to_i method for instance? There is no reason I cannot do that by default
Pretty nice solution! Very elegant, readable and simple. Though, a new array creation every iteration doesn't seem to be very good.
Very nice
The best solution. Once again it turns out that you can find the most efficient way to solve a problem just by using simple math facts
This solution is of O(n^2) time complexity but the kata has O(n) solution which isn't even tricky.