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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
The solution shows the numbers in the array being doubled not squared.
Doesn't this return an array of the elements squared? I thought they were supposed to be doubled.
I think there's something wrong with this solution!
thx! :) (Note: do not forget the spoiler flag, when you throw bits of code in the comments: they are visible from anyone in their dashboard)
This comment is hidden because it contains spoiler information about the solution
What list lengths were tested? If it's function calls that are expensive, it's still a constant factor, it may be able to significantly affect times for only really small lists.
@KenKamau: I understand. Don't get me wrong, this wasn't meant as criticism, just as a fun little observation in case other users wondered if and how the two top voted solutions differed.
@Unnammed: My comment was based on the following timeit results (first fct is sum(arr1+arr2):
So as you can see the performance difference is very small, but it's there. My best guess is that's caused by the additional function call which to my knowledge can be pretty expensive in Python.
Proof? I don't believe adding numbers can be slower than adding the same numbers and allocating memory for a whole list and copying everything.
It's 8 Kyu. I don't think about performance in such Katas.
This comment is hidden because it contains spoiler information about the solution