Problem 44381. Cache me Outside
Solution Stats
Problem Comments
-
6 Comments
Whoops, accidentally had the answer in the test suite. Fixed now.
Bryant,
Any chance you can elaborate a bit? I can make a memoized fibonacci code, but that's not really what you're asking. I don't get what the function call with 2 arguments (and 2nd argument the function itself) is in the test set: seq = memfib(n-1, memfib);
Sorry for the confusion.
Paul, it uses a feature that was just introduced in R2017a. If the answer hadn't accidentally been in the test suite, I never would have figured this one out either!
I tried comparing this code with a non-memoized version, and it was 6 times slower!
Love the name of the problem.^^
As difficult as the problem looks, (one of the) solution is quite easy and straight forward.
Problem Recent Solvers91
Suggested Problems
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1343 Solvers
-
How many trades represent all the profit?
574 Solvers
-
Create a Multiplication table matrix...
370 Solvers
-
Find out missing number from a vector of 9 elements
282 Solvers
-
69 Solvers
More from this Author56
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!