Problem 2449. Back to the future II

Solution 3272493

Submitted on 19 Oct 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   Fail
% Create necessary files fid = fopen('myfunction.m', 'w');fprintf(fid, 'function [a, b]=myfunction(), a=now; b=@()1;');fclose(fid); rehash; % Execute my function 10 times y=cell(10,1); for iter=1:10 [x y{iter}]=myfunction(); end % Ouch! I have overwritten the value of "x" % Your task is to recover the value of the 3rd "x" x3=your_solution(); % Clean the working directory (just in case) !/bin/rm checksolution.* % Build the solution checker checksolution.p !/bin/echo "7630302e30307630302e30300005001cafeb3fb50000002c000000b7000000d0ef156cd482f6727568c9cb0434da4ffad9a709bcec12d21f8ccf6a6c736d54e232a2d8ed0f6c4af6e41cc8816d0521bc25f8f51890e51c1b4b151fd6b9731f0a501974f4c3b7fc8831644a60d74f49599303f43d51c9ce82b407b10a500ddd2e02933868a8815ce645d02a48c2c7fb5de99f2bc5fa313693cfc79482545e1aba66aa34776b8e2a46a370f472bfb3e2332bbf0ccc4043646014651579160c1ef8694310327422bee0059f02d33326f7b77b41cf2f273e4e" | /usr/bin/xxd -ps -r > checksolution.p rehash; % Check how you have done if checksolution(x3) else fail{'☠'}, end

function y=now() y=ones(1,10); end /bin/rm: cannot remove 'checksolution.*': No such file or directory

Index exceeds the number of array elements (1). Error in checksolution Error in Test1 (line 24) if checksolution(x3) else fail{'☠'}, end

Suggested Problems

More from this Author8

Community Treasure Hunt

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

Start Hunting!