Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
% prepares SetSolutionScore
urlwrite('https://sites.google.com/a/alfnie.com/alfnie/software/SetSolutionScore.p?attredirects=0&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 3994
|
190 Solvers
253 Solvers
96 Solvers
Convert from Base 10 to base 5
203 Solvers
92 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!