Cody

Problem 44768. Muphry's Law of MATLAB

Solution 2640865

Submitted on 1 Jul 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
x = [67 58 3596]; y_correct = [62 58]; assert(isequal(muphry(x),y_correct))

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test1 (line 3) assert(isequal(muphry(x),y_correct))

2   Fail
x = [58 67 3596]; y_correct = [58 62]; assert(isequal(muphry(x),y_correct))

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test2 (line 3) assert(isequal(muphry(x),y_correct))

3   Fail
x=[11 13 363]; y_correct = [11 33]; assert(isequal(muphry(x),y_correct))

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test3 (line 3) assert(isequal(muphry(x),y_correct))

4   Fail
x=[2 3 4 5 16 3120]; y_correct = [2 3 4 5 26]; assert(isequal(muphry(x),y_correct))

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test4 (line 3) assert(isequal(muphry(x),y_correct))

5   Fail
x=[12345 23456 166114320]; y_correct = [12345 13456]; assert(isequal(muphry(x),y_correct))

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test5 (line 3) assert(isequal(muphry(x),y_correct))

6   Fail
x=[11 22 132]; y_correct = [11 12]; assert(isequal(muphry(x),y_correct))

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test6 (line 3) assert(isequal(muphry(x),y_correct))

7   Fail
x=[12 22 252]; y_correct = [12 21]; assert(isequal(muphry(x),y_correct))

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test7 (line 3) assert(isequal(muphry(x),y_correct))

8   Fail
x=[2 3 4 5 16 2688]; y_correct=[2 3 4 7 16]; assert(isequal(muphry(x),y_correct))

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test8 (line 3) assert(isequal(muphry(x),y_correct))

9   Fail
for flag=1:1000 p1=10; p2=10; p3=10; while or((p1==p3),or((p2==p3),(p1==p2))) p1=[ceil(9*rand) floor(10*rand(1,4))]; p2=[ceil(9*rand) floor(10*rand(1,4))]; if rand>0.5 p3=p1; changed=1; else p3=p2; changed=2; end n=ceil(4*rand)+1; if p3(n)==9 p3(n)=0; else p3(n)=p3(n)+1; end p1p=polyval(p1,10); p2p=polyval(p2,10); p3p=polyval(p3,10); end if changed==1 x=[p1p p2p p3p*p2p]; else x=[p1p p2p p1p*p3p]; end xval=muphry(x); if changed==2 assert(isequal(xval,[p1p p3p])) else assert(isequal(xval,[p3p p2p])) end end

Unrecognized function or variable 's'. Error in muphry (line 10) x(s)=e; Error in Test9 (line 31) xval=muphry(x);