Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Correct

16Size
Leading solution size is -10.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
% Clean workspace
!/bin/cp get_me.m safe
!/bin/rm *.*
!/bin/mv safe get_me.m
!/bin/rm @*
% Clean user's function from some known jailbreaking mechanisms
functions = {'!','feval','str2func','regex','system','dos','unix','perl','java','fopen','write','save','setenv','path'};
fid = fopen('get_me.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 = get_me()\n%%%s', st);
fid = fopen('get_me.m' , 'w');
  fwrite(fid,st);
fclose(fid)
% Release the Kraken!
get_me()
% Try to cleanup the mess
!/bin/cp get_me.m safe
!/bin/rm *.*
!/bin/mv safe get_me.m
!/bin/rm @*
path(pathdef) % undo any change on search path
assert(isequal(ans,now))
/bin/rm: cannot remove `@*': No such file or directory
ans =
     0
ans =
     0
[Warning: Function /users/msssystem2/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[  In get_me at 4
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14
  In workspacefunc at 7]
[Warning: Function /users/msssystem2/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[  In get_me at 4
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14
  In workspacefunc at 7]
[Warning: Function /users/msssystem2/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14
  In workspacefunc at 7]
/bin/rm: cannot remove `@*': No such file or directory
ans =
  assert with no properties.