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
First time my code is on par with the top result. I usually feel like a noob coder at this point but not today. Woohoo!
nice code
Nice, good job!
This comment is hidden because it contains spoiler information about the solution
This is brilliant. Thanks!
This comment is hidden because it contains spoiler information about the solution
Can it pass the test such as solution(["a","b","c"],3,"a")? I think it should return a
Does this qualify as "easily?"
signmod = index < 0 ? 1 : 0
(index.abs() < items.length + signmod ) ? items[index] : default_value
@wchargin, I think it's fine to use the ternary ? operator here. Is that what you meant by this isn't very Ruby?
See http://stackoverflow.com/questions/4252936/how-do-i-use-the-conditional-operator-in-ruby
This isn't very Ruby. (1) you should use the builtin
fetch
, (2) if not, you should useunless
statements instead.I did the same thing without recursion. Now I feel bad of my solution. Yours is just brilliant. Good job =)
This comment is hidden because it contains spoiler information about the solution