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.
The translator has been inactive for a year, so ...
self_init ()
was missingFor an 8 kyu kata, error messages should be more informative.
For example, see test code in the following kata: https://www.codewars.com/kata/5168bb5dfe9a00b126000018/ocaml
Duplicate issue.
Note that the task asks to produce an array (read: vector), and this will return a seq. Tests pass nonetheless. Rant mode off.
In Haskell version, I don't know what the original problem is, but at least from reading the problem statement, I think that when the input
Just [0]
is given in a random test, the answer should be[0, 0]
(the above code would give[]
as the answer). BecauseJust [0]
is neitherNull
norEmpty
, it shouldn't return an empty list (and I've been hitting random tests like this).You're right, I was out of touch with the two test cases. I've rewritten the code to calculate up to
fib 10000
. OCaml is a bit strict with numbers, so I'd rather not write something like that ;).Personally, I think recursive memoization is one approach to dynamic programming (compute from before or after), but I'll consider the dynamic programming approach too!
You're missing a couple of test cases.
Also, can you do it without memoisation? I did this whole thread to figure out how to do it with dynamic programming instead of memoisation.
I started understanding a bit of dynamic programming one day, and realised that this way of calculating Fibonacci fit the definition.