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.
Any difference with looping through
smileys
first then check membership inarr
?You are right, my solution is shorter. I solved it without lambda :D
This comment is hidden because it contains spoiler information about the solution
It avoids unnecessary computation in the event of an empty input.
This comment is hidden because it contains spoiler information about the solution
No problem :)
Mutating an array in a function is usually a bad practise because it modifies it permanently and you cannot revert the process. Mutating an array is good as long as it is a method of a class, for example: python has .sort() which is a method of the list class.
The Kata author has done:
What happens is that your solution ("invert" function) will modify the original array, and this modified array will be the parameter for the user's solution ("answer" function); therefore changing out the real expected solution.
I'm not sure if the Kata author did this accidently or purposely, but this "issue" is fine to be left because it stops people modifing the original array (deterring them to stop modifying the parameter). When making a Kata, I would usually do the same, however, I would inform the user not to mutate it in any way.
It can be "fixed" by:
Don't modify the original array.