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.
Making the cache private is a bizzare "extra challenge". I can't see how that provides any better functionality/encapsulation, if anything it just makes it harder to understand.
The calls to fibonacci(n-1) and fibonacci(n-2) will store the value in memo, no reason to do this multiple times.
n is either fib(n-1) and fib(n-2)
In this solution, only fibonacci(n) is stored in the memo. But since fibonacci(n - 1) and fibonacci(n - 2) are called, they can also be stored in the memo, so if the next test is fibonacci(n - 2) for example, the result will already be in the memo.
which is exactly what is done here... Or are you talking about the base cases?
You should store the fibonacci(n - 1) in memo[n - 1] and the fibonacci(n - 2) in memo[n - 2]...
The most "production-ready" solution, IMO. Really clean and efficient.
yes
This comment is hidden because it contains spoiler information about the solution
Can you pls provide more data?
I see many successfull solutions on coffescript.
It may use powerful built-in features, but subsequences(s) runs in O(2^N) time, where N is the length of s. This makes this solution prohibitively slow for long strings (MUCH slower than a dynamic programming solution, which will have O(N^2) time complexity).
This is by far the most elegant solution. A+ for the loop comprehension.
CoffeeScript version simply does not work; appears to be missing tests on submit.
Very elegant solution. Couple of style suggestions: the for loop could be condensed to 'for i in source if i in caps' since the string form isn't needed, and 'True if b == [] else False' could be rewritten as 'return not b'.
EDIT: nevermind
Loading more items...