Cody

Problem 44768. Muphry's Law of MATLAB

Solution 3290603

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

Suggested Problems

More from this Author80

Community Treasure Hunt

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

Start Hunting!