Cody

Solution 700021

Submitted on 13 Jul 2015 by Jan Orwat
  • Size: 378
  • This is the leading solution.
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
%% % prepares SetSolutionScore urlwrite('https://sites.google.com/a/alfnie.com/alfnie/software/SetSolutionScore.p?attredirects=0&amp;d=1','SetSolutionScore.p'); rehash path; SetSolutionScore(5000); % download Megan model unzip('http://www.mathworks.com/matlabcentral/fileexchange/51139-megan-simulator--xkcd-zip-file?download=true'); !/bin/mv Megan/* .; /bin/rmdir Megan % gets x1 x2 vectors [x1, x2]=MeganWalk(); assert(isequal(size(x1),[20 1])&isequal(size(x2),[20 1]),'incorrect output sizes'); assert(max(max(abs(x1)),max(abs(x2)))<=2,'vector values beyond 2'); % tests trajectory t = 0:1/20:4-1/20; x = x1*sin(2*pi*t) + x2*cos(2*pi*t); mg=drawMegan(x,[],... 'scene','none',... 'defs_physicsspin',0,... 'plot',0); close all; % distance walked pos=mg.state.laststep(1:2); distance=round(-pos(1,2)-abs(pos(1,1))); str=sprintf('Distance walked %d',distance); disp(str); % sets solution score SetSolutionScore(5000-distance); assert(distance>100,str);

Distance walked 4622