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 is a very efficient and creative solution; that said it sacrifices some readibility for that efficiency.
the nums[1:] in range will create a new slice without first element, and we compare "v" with arr[i] (previous element of slice nums)
[0.2, 1.2, 1.4, 1, 1.2, 10, 1.4, 124]
this function work not correctly
It would fail. In my case (and I suppose not only mine) there was an array with 5 different numbers and only one of them was unique.
I know the test cases don't cover it, but what if at least one of them was 0? ;-)
Mine is exactly same as yours, (each line and each word) :P :P
Well, returning 2.0 isn't really an error. The description didn't define the behavior for invalid inputs. From the description, "There is an array with some numbers. All numbers are equal except for one." Your list doesn't match the expectations for this kata, so I'm not sure what you expected to be returned.
When [1.0,1.0,1.0,2.0,2.0,3.0] result is errors
for i, v := range arr[1:] to skip a few elements in the array
Slick, also the most efficient. Well Done.
🤔
Not an issue.
This comment is hidden because it contains spoiler information about the solution
Loading more items...