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.
Very nice kata on optimization, great.
Ok, thanks for clarification
This Kata uses a very ridiculous optimization technique. Let's just say, the Kata really wants you to optimize the fact that only up to exactly a million elements will tested. It's overkill if you ask. Your algorithm is likely correct, but try to aggressively optimize everything other than your algorithm too.
I think there is a problem with this kata. I prepared a solution and tested it on my local machine + js sandbox. My solution returns the variable "result" which is integer. When I make an attemp - it works slowly and as a result i caught timeout error. My solution is correct(there is no proble with it), it is executed vast everywhere except codewars. Moreover, I get the right answer during my code execution. The problem is in the output. If I convert my answer to string(for instance) - I get an error that MY ANSWER IS WRONG BECAUSE OF THE TYPE MISSMATH, but I see that the result of my calculation is right and mathces the final answer of this kata(the same situation happens when I convert the "result" variable to object). Could you please take a look at this point? If it is needed, I can post my solution in this chat
Haskell translation
Ruby translation kumited -- please check and approve!
Python translation. Please, review and approve.
The Example is wrong.
rec(0) == 0
rec(1) == 0
rec(2) == 1
rec(2) == 4 //should be rec(3)
rec(2) == 10 //should be rec(4)
rec(5) == 12
Idk really. IMO, the only hard part is understanding how to properly memoize the results, and even then it is very easy to implement it.
For some reason CW invalidated all solutions except for his one O_o
I think you've overdone it. Notice that nobody is interested anymore - yours is the only solution. ( Zed's is a remnant of simpler times. )
Then again, I've never been interested in ridiculous performance. And / or I just suck.
Reference solution takes mere
3.5 - 4
seconds, so your code can be at most twice as slow to pass the tests ;)Generating the sequence is easy, but you should think well about how to deal with the other parts of the tasks.
Seems a bit hard for me. I tried solving it with memoization, but my code times out on random tests. Though maybe I just suck. ;(
Loading more items...