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.
wow, I never thought of using spaceship operator. Nicely done
Well, that's after I changed this:
For this:
Any idea why the first one gave that error instead of the out of bounds? I mean, hiding the real problem.
As it says, one of the arguments of the
+
inside the innerloop
isnil
, which means the index is out of bounds.I saw it, but still I have no idea why that happens, sorry. Maybe someone who's more fluent in Ruby could find out why.
Hi Chrono79. I pasted the the solution that passes about 10 tests before getting that weird NoMethod error above if you want to replicate. Thank you :-)
This comment is hidden because it contains spoiler information about the solution
I'm gonna explain why that happens (I hope), but that part of the code should run only if your function isn't called
two_sum
.And it's there for compatibility reasons. The Ruby translation used camelCase instead of snake_case at first and then that was changed. No idea why it would pass some tests and fail randomly. It doesn't happen with my solution.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I got that twoSum error too with Ruby. I've printed it out below. Mine passed about 8 tests before failing this one.
main.rb:37:in
rescue in block (2 levels) in <main>': undefined method
twoSum' for main:Object (NoMethodError)Did you mean? two_sum
Part of me wonders if a test has twoSum as one of the method calls most likely me that's made the mistake though :-)
What language?
This comment is hidden because it contains spoiler information about the solution
Thanks for this. Really enjoyed it. It was tricky to work out intially how to solve it. Loved the many different solution types people had. Great.
Oh wow. Such a creative way of solving this. Very nice indeed.
It took a while until I realised the alphabet was extended. I'll definitely steal this :-)
Wow I love this solution. So simple, concise and clear.
Loading more items...