Cody

# Problem 44381. Cache me Outside

Solution 1322076

Submitted on 31 Oct 2017
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
memfib = memoize_this(@fib); [seq, n1] = fib(1, memfib); assert(n1 == 1); [seq, n2] = fib(20, memfib); assert(n2 - n1 == 19); [seq, n3] = fib(100, memfib); assert(n3 - n2 == 81); function [seq, n] = fib(n, memfib) persistent num if isempty(num) num = 1; else num = num + 1; end if n < 3 seq = ones(1, n); else seq = memfib(n-1, memfib); seq = [seq, seq(end-1) + seq(end)]; end n = num; end

Index exceeds matrix dimensions. Error in memoize_this>myFun (line 11) m(n) = fcn(n, []); Error in memoize_this>myFun (line 11) m(n) = fcn(n, []); Error in Test1>fib (line 24) seq = memfib(n-1, memfib); Error in Test1 (line 6) [seq, n2] = fib(20, memfib);

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!