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]...
i did it like this but in array XD. thank you for this
almost the same
I thought it was just Problem 1 on Project Euler, and the root also contains a solution to the problem, which is why I thought it was fine.
I'm not sure how to redact a Kumite, but I can do that if you would like.
Do you realize that you're casually discussing a solution to at least 2 katas here?
Print your input and check what exactly your function cannot handle correctly.
I only got 3 failed, can someone tell where i can see my mistake?
How to know the error? i got 8 error but i dont know my error
Hi, Actually i had same thoughts about if else heirarchy(still i have same).
Before writing this comment i executed following code in C in Code Blocks 16.01
int x=1;
if(x==1)
printf("1");
else if(x>0)
printf("2");
else if(x<3);
printf("3");
and i got 13 as answer(in C) so based on this fact that if else is same for every programming language i commented on this.
but but i also tested this in differnet language after reading ur comment i got answer as 1 only.
That's not how
else if
s work. Once oneif
is satisfied, it breaks out of theelse if
chain. By your logic, 15 would actually be added thrice:15 % 3 == 0
and15 % 5 == 0
so that will trigger the first one, then the secondelse if
will trigger and so will the third.The test case implies there is an array being passed, yet you say that
number
is not an array.Edit: Also, you are simply
console.log(abc)
rather thanreturn abc
, might that be the issue?Loading more items...