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.
Thanks zebulan! That was really helpful.
It definitely can be improved, and I will refactor it when I have the time, since from what I see, other people read those solutions. For this kata I focused on quickly writing this faster approach and just testing that it works. However, I don't think it's too long, which was your original concern. You just didn't understand it.
If my code is hard to follow for you, I'll explain. I do prime factorization, and then compute combinations of those factors to get all divisors. I didn't write it for anyone to read, that's why it's all in one function and variables are named poorly.
Oh I never said my code was pretty, it's very far from ideal. I just disagree that I should always go for the shortest code. Definitely not in the expense of readability. I agree that your algorithm fits in two lines. However,its a different algorithm than mine. I came up with your solution in the first second after reading this kata. It's the most obvious way. Unfortunately, it's not the most efficient.
BTW, have you noticed that I don't simply iterate from 2 to integer? Your one line doesn't replace my code.
Also, thanks for correcting my last line, I'm fairly new to python.
Thanks for your input. However, I strongly disagree with this approach. Making code shorter doesn't necessarily make it better. One liners tend to be hackiest and the most difficult to understand. Being able to read and understand code written by someone else is sometimes as important as efficiency. That's especially true with big projects that require maintenance. Do you know the book "Clean Code"?
Do the solutions have to be short? I'm doing this for myself and implementing the most upvoted solution seemed to easy to me.