Cody

Solution 1946025

Submitted on 22 Sep 2019 at 22:52 by Augusto Mazzei
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','round','roundn','fix','ceil','char','floor','\.','^','power'}; fid = fopen('fib.m'); st = char(fread(fid)'); for n = 1:numel(functions) st = regexprep(st, functions{n}, 'error(''No fancy functions!''); %','ignorecase'); end st = regexprep(st, 'function', 'error(''No fancy functions!''); %','ignorecase',2); fclose(fid); fid = fopen('fib.m' , 'w'); fwrite(fid,st); fclose(fid);

2   Pass
n = 1:5; f = [1 1 2 3 5]; assert(isequal(fib(n),f))

yp = 1.6180 2.6180 4.2361 6.8541 11.0902 ym = -0.6180 0.3820 -0.2361 0.1459 -0.0902 y = 1 1 2 3 5 y = 1 1 2 3 5

3   Pass
n = 7 : 10; f = [13 21 34 55]; assert(isequal(fib(n),f))

yp = 29.0344 46.9787 76.0132 122.9919 ym = -0.0344 0.0213 -0.0132 0.0081 y = 13.0000 21.0000 34.0000 55.0000 y = 13 21 34 55

4   Pass
n = 20 : 22; f = [ 6765 10946 17711]; assert(isequal(fib(n),f))

yp = 1.0e+04 * 1.5127 2.4476 3.9603 ym = 1.0e-04 * 0.6611 -0.4086 0.2525 y = 1.0e+04 * 0.6765 1.0946 1.7711 y = 6765 10946 17711