Cody

Problem 44768. Muphry's Law of MATLAB

Solution 2818204

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

62 58

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

58 62

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

11 33

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

2 3 4 5 26

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

12345 13456

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

11 12

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

12 21

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

2 3 4 7 16

9   Pass
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

97824 65600 30153 69774 82289 42157 34830 26174 28305 31888 28097 98869 13182 14103 97667 52036 97342 69390 51689 96417 45581 19722 14410 42130 15415 17928 74444 81877 91066 17168 59189 18044 65370 27876 14778 11131 47720 44184 68644 85648 97728 86939 20567 31452 77718 37614 34471 68099 70148 83028 64085 49137 76601 59845 44626 37615 46657 64619 95949 80840 15312 63269 55320 88602 51400 35874 10913 88592 21898 87342 73732 45793 24937 93722 24724 98002 58537 96731 20346 38241 65836 98106 78971 81186 52989 51050 84622 43259 70148 67385 40861 90437 69258 34450 22086 93288 19770 69115 71781 90277 98659 82883 84741 48088 69319 62797 99560 91897 47489 34246 50131 79625 13531 34297 17111 67431 15745 85486 48029 19263 61831 71934 54804 40040 21542 39621 52265 85300 85531 73894 67310 96989 23669 99341 49050 45193 20818 99610 42398 63464 42934 63698 30955 66493 51264 60109 99050 66002 80502 84765 53350 37833 40538 48688 26237 80486 46898 98711 32152 36782 62493 71444 39119 22606 76172 94514 99667 74840 36477 85449 85273 19755 76828 64440 43819 93978 43581 94822 89954 55744 87233 62511 68855 64774 96761 13062 89731 63844 27438 78859 53464 67692 32197 52560 26980 59912 52360 73811 88572 62044 17482 71920 94394 28168 73128 23232 11212 73083 31198 16996 33503 96190 45543 30329 55821 85185 81738 62544 55069 18329 98030 32747 66110 33087 45829 11705 75192 78601 28881 93289 89682 69773 81957 23686 88418 35606 78729 87460 28175 13994 20474 45173 70901 92838 97020 71566 85590 92293 70744 31901 95030 18398 55295 21220 84392 10273 53108 57145 52942 65235 17248 32570 49050 20180 72728 59936 81640 88185 85976 48733 86307 39053 30720 66111 60826 54278 64578 12410 25182 14578 69243 32518 77012 39650 70251 60270 72691 17969 51228 46763 93115 31937 87529 36963 28253 94266 94780 69606 45521 42874 89926 25793 94546 92894 25694 67191 34943 90807 36069 35487 56756 75634 65394 18285 73232 16023 55531 30060 93359 72141 17073 27376 25889 35964 82081 70928 74398 16712 22645 59475 70061 73393 10498 88527 74671 90256 71421 31912 92453 48162 22935 35699 44780 87369 66981 70395 74718 76543 67552 54429 72852 10106 16115 76910 57808 21271 42593 97527 34412 86786 48815 81039 41842 92922 38614 71606 95376 44656 80765 62863 82640 57329 11352 31091 22112 16982 76610 54988 10577 35753 56893 89614 57632 25874 38989 33471 67340 36104 16069 64586 96211 46852 30731 92739 29831 46662 47891 30011 48923 80131 58928 70997 75793 19856 49794 40727 71030 62882 50333 56405 91179 98821 15521 17826 83096 60242 13406 94786 32269 49311 54149 68047 18467 72285 70996 89729 82743 74983 57765 57589 61698 99830 31358 23019 78996 87183 65645 58701 66891 59700 24326 23556 95024 80250 54433 90667 61771 12202 94963 91850 33855 82131 27449 72877 29003 91355 95918 47574 39489 48468 37305 42375 11735 36763 25631 10684 48270 37159 90476 36755 27029 29780 18377 91702 34317 14054 13443 66794 19084 65718 58036 99872 56639 61431 49744 26478 40316 25744 74945 91597 68364 36127 20998 16165 89626 52883 97926 30539 19765 62581 79280 36276 53258 72398 33768 68071 45483 66148 27226 98155 60146 40813 84457 77856 96021 15929 59667 25988 36219 70657 45034 91157 34370 89542 23067 68647 98440 76455 47356 34534 86238 68503 14274 92485 29400 76253 71063 52064 37816 97391 86912 79794 58834 36589 92754 57317 13410 70195 85172 12907 60794 74321 30458 27910 35196 86094 85194 91569 40828 77581 98185 43748 20370 74640 15932 20853 76003 10762 12769 28050 35380 99532 51073 63276 46957 23947 21549 80221 93974 17333 45588 14261 89191 45737 81893 32571 55498 39762 38522 18215 18965 63398 52865 55072 98765 55383 30456 77332 73389 51899 19879 17511 20378 14643 93757 38859 71011 64289 77630 37341 90373 72940 52496 95001 18679 93344 99490 84176 22072 84751 74635 74909 78273 74435 91300 69804 93483 28600 67785 71331 85757 17036 92953 10014 61279 45338 13942 44640 56917 48141 14116 72971 52605 21710 70136 17804 70530 98559 12092 43341 82322 46798 23997 31740 74335 23877 96832 79782 94702 92495 83518 48455 89327 64731 87900 16255 58874 53516 95512 64224 96677 14760 53162 91792 42312 16795 90835 65517 78109 47485 42351 46507 52977 16851 37702 51596 86636 72603 85732 13960 21460 26048 28643 12427 34463 58750 92496 39077 44615 30398 58783 27806 45630 36364 53405 21511 68911 74925 53343 60592 32714 62374 10180 54541 86785 30580 24209 90778 55362 83606 30086 42847 53045 45668 33788 86171 87532 22915 10633 15875 47806 23514 62246 47688 10435 42287 85020 69480 75386 63926 14818 10471 99856 76811 39528 11622 61873 35915 74218 96736 99367 63817 55171 66375 60628 57327 88490 28748 64082 32390 57360 45453 48745 32553 98078 30272 13885 16796 38629 3293...

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!