Cody

Solution 486575

Submitted on 14 Aug 2014 by rifat
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
%% % Clean workspace !/bin/cp my_function.m safe !/bin/rm *.* !/bin/mv safe my_function.m !/bin/rm @* % Clean user's function from some known jailbreaking mechanisms functions = {'!','feval','eval','str2func','str2num','regex','system','dos','unix','perl','java','fopen','write','save','setenv','path','fft'}; fid = fopen('my_function.m'); st = char(fread(fid)'); for n = 1:numel(functions) st = regexprep(st, functions{n}, 'error(''No fancy functions!''); %', 'ignorecase'); end fclose(fid) % Force a function header, and comment first code's line (the supposedly users' function header) st = sprintf('function y = my_function(x)\n%%%s', st); fid = fopen('my_function.m' , 'w'); fwrite(fid,st); fclose(fid) rng(now); input = rand(1, 1000); output = my_function(input); % just ignore this !/bin/cp my_function.m safe !/bin/rm *.* !/bin/mv safe my_function.m !/bin/rm @* path(pathdef); % undo any change on search path assert(sum(abs(output - fft(input))) < 1e-8) % accounts for some FP errors

/bin/rm: cannot remove ‘@*’: No such file or directory ans = 0 ans = 0 /bin/rm: cannot remove ‘@*’: No such file or directory [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/hdlcoder/matlabhdlcoder/matlabhdlcoder] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/hdlcoder/matlabhdlcoder] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos/dataclasses] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos/industrial] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink/frameedit] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/asap2/asap2/dataclasses] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/asap2/asap2] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/asap2/asap2/user] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/common/can/blocks/dataclasses] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/common/can/blocks] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/common/can/blocks/tlc_c] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/common/tgtcommon] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/coder/simulinkcoder/cgv/API] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/rtw/misra] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/coder/simulinkcoder] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/pil] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos/aerospace] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink/modeladvisor] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink/modeladvisor/fixpt] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos/simfeatures] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/components] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/dee] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/blocks] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink/dataclasses] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink/MPlayIO] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink/dataobjectwizard] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink/slresolve] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simulink/mdlrefadvisor] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/AUTOSAR/AUTOSAR/dataclasses] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/targets/AUTOSAR/AUTOSAR] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/accel] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/coder/simulinkcoder_core] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/sdi] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos/simgeneral] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos/automotive/fuelsys] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/rtwdemos] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/rtw/rtwdemos/rsimdemos] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos/automotive] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/simdemos/automotive/powerwindow] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/blocks/library] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/blocks/library/simulinkcoder] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/simulink/blocks/obsolete] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/stateflow/stateflow] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/stateflow/coder] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/matlab/R2014a/toolbox/stateflow/sfdemos] [> In path at 33 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Name is nonexistent or not a directory: /opt/mlsedu/mat...