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.
It's nice, I had similar solution, but even now I cannot pass performance tests with it.
I'd probably wrap it in a class and refactor #go_up and #go_down, but it's working ;).
This comment is hidden because it contains spoiler information about the solution
I suspect your solution is faster because it doesn't have to create additional Arrays like the
each_cons
in my solution does.Most of the time I go for readability over performance unless it's a particularly critical piece of code.
I had another go at this one, what do you think?
Man, great job, but I don't understand what is the rule it follows. How did you find the pattern?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Why not (1...num)? And why do you need inject(0, &:+) instead of inject(:+)?
Neat, no iteration included :).
Can you explain why flatten is better?
I tried this in Ruby 2.2.2 and it works, when you put it into method. However it doesn't work in irb.