Cody

# Problem 42248. Return fibonacci sequence do not use loop and condition version 3

Solution 2567088

Submitted on 16 Jun 2020
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   Pass
% !/bin/cp fib.m safe % !/bin/rm *.* % !/bin/mv safe fib.m % Clean user's function from some known jailbreaking mechanisms functions={'!','feval','eval','str2func','str2num','regex','system','dos','unix','perl','assert','fopen','write','save','setenv','path','please','for','if','while','switch','global','figure'... 'round','roundn','fix','ceil','char','floor','\.','^','pow','\^','sscanf','persistent'}; fid = fopen('fib.m'); st = char(fread(fid)'); for n = 1:numel(functions) st = regexprep(st, functions{n}, 'error(''No fancy functions!''); %','ignorecase'); end fclose(fid); fid = fopen('fib.m' , 'w'); fwrite(fid,st); fclose(fid);

2   Fail
n = 2; f = fib(n); assert(isequal(f() + f(),f())); assert(isequal(f(),5));

Undefined function 'merror' for input arguments of type 'char'. Error in fib (line 2) ff = merror('No fancy functions!'); %er([0 1; 1 1],n) * [0;1]; Error in Test2 (line 2) f = fib(n);

3   Fail
n = 7; f = fib(n); assert(isequal(f() + f(),f())); assert(isequal(f() + f(),f())); assert(isequal(f(),233));

Undefined function 'merror' for input arguments of type 'char'. Error in fib (line 2) ff = merror('No fancy functions!'); %er([0 1; 1 1],n) * [0;1]; Error in Test3 (line 2) f = fib(n);