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.
Because you can't do
[1 1]
. And I have already explained it in the post above yours.1 x 1 = 1, that is why it should be in there. The number and itself happens to be a divisor. There's also no special criteria that says the array of divisors has to be unique.
The example provided in the description of the kata for the number 246:
[1, 246, 2, 123, 3, 82, 6, 41]
1 x 246 = 246
2 x 123 = 246
3 x 82 = 246
6 x 41 = 246
Makes sense, since all the numbers are in the array.
When we try to produce the first step for number "1":
1 x 1 = 1
It should produce [1,1].
Can you mention why it shouldn't be [1,1]?
schanjr why do you say?
There is only one divisor of 1 and that's 1, why do you write it twice there?
Buddy, just because people can (and did) hardcode solutions to solve this issue, doesn't mean your kata doesn't have an issue.
It got marked as Best Practices, but here the idea is to solve it yourself instead of using libraries...
Not a kata issue. Before posting issues look at the top of the page: 433 people passed the Ruby kata (out of 18127). If there were errors in the kata someone would have seen them before you. Cheers.
This comment is hidden because it contains spoiler information about the solution
Probably the best solution here in terms of algorithm. The one that got upvoted the most looks prettiest.
Blows my mind everytime I see a short solution like this.
It's linear, so it scales ok. Sure it's not optimized for very different lengths case, but optimized != best practice.
Best practice is right compromise between optimization and code clarity.
short solution is what I would say, but not Best Practices. Does not scale well if one list is a lot longer than the other one. It would store too much into the memory.
From my understanding, your "copy" just means creating separate memory address, and not referencing to the original object directly.
Your instructions can be challenging for those without CS major.
I actually never knew this. This is about 25% faster than the traditional method of 2 ** 5. Going to treasure this nugget of knowledge forever.