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.
filter method only returns truthy values, so falsy (cache[n]> x) won't be returned.
This comment is hidden because it contains spoiler information about the solution
And you're absolutely rignt 'You need to design a recursive function called replicate'
Sorry but no. I had recursion beaten into me while in Computer Science faculty. And once I got the basic idea of it, it just stuck with me.
But I can point you to algorithms with which I had first experience with recursion (all of them are sorting algorithms btw). Those algorithms are: QuickSort, MergeSort and HeapSort.
Also always keep in mind. Every recursive function can be turned into iterative function (for some stack may be needed (if they are not tail recursion)).
TL;DR for tail recursion: If the last thing you do in recursife function is a call to itself, than it is tail recursion. Like this solution :). And other solutions for this problem.
Also maybe check out the collection of books by Donald Knuth called The Art of Computer Programming, WIKIPEDIA. So far those books are far the best if you want to learn algorithms and how they work.
Thanks.
Knowing ES6+ shortens your code alot. :)