Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 338285

Submitted on 23 Oct 2013 by Tim

Correct

195Size
Leading solution size is 132.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
tic
zee=[0 0 0 1];
zm=[97 68 ];
vexp=165;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
2
Pass
 
%%
zee=[1 0 0 0];
zm=[11 ;92 ];
vexp=103;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
3
Pass
 
%%
zee=[0 0 1 1];
zm=[47 -1 ;-1 41 ];
vexp=-1;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
4
Pass
 
%%
zee=[0 0 9 9];
zm=[9541 9311 1035 9921 9342 2262 8685 7151 184 8189 ;3885 4455 8295 4011 4030 7427 4325 7756 3404 3014 ;4402 9158 999 4298 6612 1696 5965 1822 9039 12 ;6015 8579 9322 7049 4851 5015 5663 9888 8517 5846 ;4428 2402 6653 9074 2764 682 6500 3440 8437 6256 ;6453 9191 1765 7452 3488 8377 5499 9452 6550 4537 ;5815 8916 9467 1489 5965 4317 2855 1627 556 1372 ;3824 1335 125 476 409 9240 1158 6908 2679 5946 ;9515 9131 5136 1280 2934 8623 6008 8432 4427 8909 ;2968 241 7825 8786 8081 3789 9455 936 1767 10 ];
vexp=135772;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
5
Pass
 
%%
zee=[0 0 9 9];
zm=[2307 5590 1345 8783 2418 1753 4374 9927 5012 7052 ;5872 879 2534 7360 2158 1820 5982 4517 251 6760 ;3425 9571 3353 1249 8356 1433 1389 7810 2368 9507 ;4172 1026 1449 1868 9808 3866 3620 533 3792 4983 ;7584 6015 5861 6470 3374 4370 8289 5708 8886 4891 ;8819 2311 813 2171 9911 5521 3604 1300 9682 5971 ;806 3853 6997 2254 5720 3156 2471 5691 3689 2614 ;7026 7624 8629 9238 445 8354 3608 5085 413 8845 ;9976 9232 7507 7140 1402 7418 2660 5005 5069 8694 ;976 5874 8898 7972 4480 4618 7479 3302 6660 1167 ];
vexp=113799;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
6
Pass
 
%%
zee=[0 0 9 9];
zm=[5916 -1 5143 4544 9275 5587 9249 9234 672 9662 ;-1 6999 8893 5585 490 6646 9354 9502 1651 4422 ;8195 2626 6647 7092 6949 7478 8061 779 780 1073 ;1946 6695 1109 3440 7590 6735 9026 6838 5968 6049 ;2851 398 3047 8095 2334 3537 4741 1687 9390 6391 ;6108 7584 5368 2754 1027 8668 232 9088 9446 1011 ;6512 7743 4057 3972 1182 1646 707 6560 4835 3026 ;2608 4038 3423 2007 2132 5756 1895 6872 7442 1284 ;9614 9901 8867 1333 2655 6245 6352 9238 1684 2150 ;6600 8195 6244 656 2167 3778 8653 2873 337 3487 ];
vexp=-1;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
7
Pass
 
%%
zee=[0 0 9 9];
zm=[5898 9296 7524 5673 1302 6008 7780 3196 9231 5222 ;4479 5197 5122 9697 6529 4128 5942 9233 3365 7625 ;7734 9964 5820 3977 6971 4338 7754 5623 3562 4442 ;5462 5811 3738 9337 1483 1391 5344 9263 4587 4575 ;836 5417 9771 2309 1466 2651 6437 7407 8235 6153 ;1383 5968 2469 3554 6297 9439 7891 402 1414 7804 ;4844 6875 3615 4933 2563 1449 6323 7907 7063 7261 ;8833 7898 9030 4955 6559 495 3957 9347 7901 2192 ;5499 5635 4511 4319 9189 807 110 3431 7561 -1 ;1235 8756 4749 4849 3688 7311 6297 6362 -1 9712 ];
vexp=-1;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
8
Pass
 
%%
zee=[4 2 0 9];
zm=[-1 3591 -1 9384 6034 8580 2003 -1 8780 1295 ;5605 1377 2240 559 -1 -1 4017 4895 4437 -1 ;-1 -1 -1 9865 -1 1505 2777 -1 436 8170 ;1900 6344 8059 9498 8256 -1 7952 7551 -1 5927 ;-1 -1 7609 -1 1257 1902 -1 8040 4203 -1 ;1361 2292 1143 769 -1 -1 -1 -1 2197 -1 ;3846 -1 2480 -1 -1 -1 -1 -1 -1 -1 ;4444 -1 6690 489 813 8790 -1 -1 -1 -1 ;3729 5436 -1 8544 -1 -1 -1 -1 -1 -1 ;-1 3743 -1 6213 -1 -1 -1 -1 -1 -1 ];
vexp=85015;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
9
Pass
 
%%
zee=[0 4 3 9];
zm=[256 -1 6593 -1 4076 -1 8308 8531 8388 1339 ;6280 8079 6556 5099 3523 1967 7424 -1 1469 -1 ;-1 9317 -1 6682 -1 2996 -1 3140 3913 -1 ;2927 2797 -1 9032 9111 -1 1637 5917 -1 5971 ;3285 -1 6158 5977 -1 -1 -1 6944 5424 6439 ;2389 7565 -1 5558 5485 588 -1 -1 4093 -1 ;-1 8297 -1 -1 7995 -1 -1 -1 6639 8591 ;-1 -1 -1 -1 -1 2803 5365 7702 9610 -1 ;-1 -1 -1 -1 -1 6383 -1 -1 8763 3884 ;-1 -1 -1 -1 -1 -1 4980 966 7330 -1 ];
vexp=81434;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
10
Pass
 
%%
zee=[0 7 0 9];
zm=[9117 4644 7637 2065 8336 9446 7761 9053 -1 3232 ;-1 9846 -1 898 -1 1074 -1 1715 4774 5778 ;-1 8864 -1 -1 5687 9951 5462 -1 4536 -1 ;-1 -1 -1 -1 -1 7870 -1 7507 1777 4773 ;-1 -1 89 3307 79 1280 -1 -1 -1 2898 ;-1 -1 -1 -1 4952 -1 2748 572 1991 5243 ;-1 -1 -1 -1 2706 4551 -1 8752 -1 7862 ;-1 -1 -1 5293 6847 -1 -1 4293 -1 308 ;-1 -1 -1 -1 -1 8374 5932 3627 -1 9426 ;-1 -1 -1 -1 -1 -1 -1 983 -1 3561 ];
vexp=24552;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
11
Pass
 
%%
zee=[9 3 9 0];
zm=[-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 3869 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 7888 2830 -1 -1 -1 -1 -1 -1 ;-1 257 4329 -1 2131 -1 -1 -1 -1 -1 ;-1 2582 -1 6446 8398 -1 -1 6063 6484 -1 ;8837 9043 5373 9819 -1 8087 -1 6474 -1 1335 ;866 -1 4087 -1 424 8975 1557 4839 -1 5800 ;868 7116 -1 6357 8115 -1 8722 -1 1184 5178 ;-1 8558 9689 2863 -1 3838 -1 1762 -1 6184 ;9784 3468 -1 6082 8935 7345 1958 7935 9830 2768 ];
vexp=40444;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
12
Pass
 
%%
zee=[0 0 9 9];
zm=[1 2 3 4 5 6 7 8 9 10 ;11 12 13 14 15 16 17 18 19 20 ;21 22 23 24 25 26 27 28 29 30 ;31 32 33 34 35 36 37 38 39 40 ;41 42 43 44 45 46 47 48 49 50 ;51 52 53 54 55 56 57 58 59 60 ;61 62 63 64 65 66 67 68 69 70 ;71 72 73 74 75 76 77 78 79 80 ;81 82 83 84 85 86 87 88 89 90 ;91 92 93 94 95 96 97 98 99 100 ];
vexp=1324;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
13
Pass
 
%%
zee=[0 0 9 9];
zm=[1 11 21 31 41 51 61 71 81 91 ;2 12 22 32 42 52 62 72 82 92 ;3 13 23 33 43 53 63 73 83 93 ;4 14 24 34 44 54 64 74 84 94 ;5 15 25 35 45 55 65 75 85 95 ;6 16 26 36 46 56 66 76 86 96 ;7 17 27 37 47 57 67 77 87 97 ;8 18 28 38 48 58 68 78 88 98 ;9 19 29 39 49 59 69 79 89 99 ;10 20 30 40 50 60 70 80 90 100 ];
vexp=1324;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
14
Pass
 
%%
zee=[5 1 4 1];
zm=[-1 -1 1134 9086 5787 -1 -1 9759 -1 ;-1 5195 1440 5405 6267 9573 4021 -1 -1 ;-1 8437 7138 1518 3828 -1 4927 7037 5390 ;4445 9948 -1 -1 8054 5367 -1 -1 6378 ;2675 6263 1410 8224 1185 1056 6214 -1 -1 ;3465 4891 179 -1 8233 3186 3146 4940 -1 ;9212 -1 622 9232 2128 -1 4591 -1 -1 ;853 2385 8569 3381 -1 31 9357 1202 -1 ;9153 437 481 3041 9860 -1 802 -1 5243 ;-1 3979 1226 -1 3966 8037 -1 7564 -1 ];
vexp=11154;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
15
Pass
 
%%
zee=[6 1 5 4];
zm=[8935 7055 9523 5947 9420 1029 1519 9655 7310 -1 ;5347 6550 956 3676 -1 -1 1605 165 9339 924 ;7608 -1 -1 -1 9106 2457 7428 1436 1464 -1 ;-1 8605 753 3273 -1 5557 -1 4895 86 471 ;6830 5364 -1 -1 -1 8767 -1 -1 1753 8126 ;1440 -1 -1 -1 7917 7380 870 -1 -1 8426 ;9518 1719 246 1756 1823 -1 -1 6500 9647 6158 ;-1 3753 9179 3752 -1 -1 3927 -1 28 8762 ;3442 1154 -1 2977 -1 -1 -1 -1 497 -1 ;5046 4922 8565 5170 9416 7140 4702 5262 5264 8821 ];
vexp=13461;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
16
Pass
 
%%
zee=[4 9 0 7];
zm=[-1 -1 -1 -1 5591 -1 6865 6361 -1 9574 ;5326 2417 -1 -1 6193 9084 1910 5890 9530 4249 ;5130 -1 -1 -1 2376 -1 -1 3886 8309 1892 ;-1 4623 6047 744 2180 817 6660 2425 2867 4950 ;-1 -1 -1 7617 1260 2832 4751 -1 -1 5698 ;-1 2864 4297 8644 3112 1812 2562 5793 4826 1341 ;737 4961 6790 3341 876 9914 9275 -1 9924 756 ;7283 3200 4971 4962 -1 8083 -1 8819 -1 7409 ;7651 5137 -1 1403 6483 -1 6406 7515 -1 -1 ;7345 1246 2469 3331 251 -1 8029 6777 3210 -1 ];
vexp=43605;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
17
Pass
 
%%
zee=[4 6 9 8];
zm=[4471 2340 6565 -1 -1 3663 -1 -1 4562 8294 ;8432 -1 -1 383 9745 3207 944 340 7820 3426 ;2977 97 5374 1193 4024 2963 2227 2262 6405 2380 ;4866 6164 3694 178 1313 4376 6297 6060 4583 9330 ;9358 7274 6389 6195 2179 -1 3397 7809 557 2087 ;1977 -1 2617 9973 -1 907 -1 5864 -1 -1 ;-1 6127 2119 7554 3268 7556 -1 4465 1297 3716 ;-1 -1 730 1361 5616 -1 -1 7981 7319 3103 ;-1 -1 6599 4345 -1 5421 7790 4406 876 1764 ;7527 -1 -1 8441 7260 9243 9942 -1 8987 -1 ];
vexp=46698;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
18
Pass
 
%%
zee=[3 5 3 4];
zm=[5297 1690 2134 6500 -1 378 99 -1 7714 7786 ;1895 -1 5584 1030 1354 3108 9637 -1 4744 4892 ;-1 7743 6128 3847 -1 9009 -1 -1 9951 -1 ;9108 2993 -1 4347 2520 1147 3077 8541 5470 2062 ;-1 6534 4545 1801 -1 -1 1137 8521 -1 7866 ];
vexp=3667;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
19
Pass
 
%%
zee=[7 6 4 6];
zm=[199 9295 8751 5145 2157 3343 -1 -1 7184 -1 ;3780 3730 6605 -1 8658 -1 3573 -1 -1 -1 ;6749 6135 -1 7631 -1 4179 -1 -1 4080 -1 ;3592 1382 9020 -1 6831 -1 6736 8383 -1 2258 ;1674 -1 4663 -1 6161 2406 268 -1 931 4237 ;100 6649 6439 -1 -1 5266 3204 4114 5940 5908 ;1230 -1 4134 6819 3172 8035 6784 -1 6391 -1 ;9181 -1 -1 7310 -1 1576 1892 5821 4469 2080 ];
vexp=12148;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
20
Pass
 
%%
zee=[5 3 2 0];
zm=[290 -1 5107 7466 7064 ;6249 -1 3213 6568 -1 ;1037 -1 4971 4915 -1 ;6851 9043 8163 1379 6540 ;2051 8939 1483 -1 4184 ;7062 137 -1 5275 9462 ;-1 -1 4316 3265 2838 ;-1 -1 1471 9758 7724 ;-1 -1 3883 -1 4987 ;6843 7025 6749 7147 1906 ];
vexp=51934;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
21
Pass
 
%%
zee=[7 2 5 2];
zm=[3900 9521 7343 2759 -1 ;5239 -1 1132 4911 3520 ;1517 9058 -1 -1 -1 ;-1 -1 -1 -1 8097 ;-1 7717 4099 5529 7959 ;-1 6950 9579 5029 -1 ;6687 9672 -1 -1 -1 ;1507 5064 2149 1922 7228 ;-1 8639 6134 -1 933 ;-1 511 -1 -1 744 ];
vexp=33414;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
22
Pass
 
%%
zee=[5 5 6 0];
zm=[6137 3305 6360 4891 6396 4463 8888 7982 ;7881 -1 4743 6730 360 4945 9032 -1 ;7273 3476 8679 -1 3569 2493 -1 7527 ;5487 562 9739 813 6484 6067 -1 9545 ;-1 5162 -1 4989 8112 -1 8032 1019 ;-1 -1 5009 404 1699 1676 5849 8070 ;1003 4164 2297 4730 4313 6194 5684 -1 ];
vexp=24377;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
23
Pass
 
%%
zee=[9 2 6 7];
zm=[8353 7263 7609 -1 2120 5314 -1 9477 1416 3433 ;-1 590 7657 2619 -1 -1 4684 9284 -1 -1 ;3862 -1 2692 4001 1891 -1 7719 6477 -1 5973 ;-1 8015 -1 -1 148 2255 3535 -1 1866 1644 ;1340 1620 3925 5165 -1 3694 4100 1434 3612 -1 ;7843 -1 -1 1391 7637 -1 5855 -1 7250 9629 ;1768 2379 -1 -1 3330 410 -1 9549 -1 -1 ;9493 9719 4813 1231 -1 -1 -1 5478 -1 5106 ;82 8285 251 6695 8652 -1 4552 79 -1 3502 ;3118 7594 8758 -1 -1 -1 8470 4711 -1 2424 ];
vexp=-1;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
24
Pass
 
%%
zee=[5 4 7 0];
zm=[6808 5848 -1 9349 6503 5045 2772 -1 -1 8778 ;9668 4184 2263 -1 1288 1153 2705 7033 2495 -1 ;5880 2410 -1 7454 -1 2978 2427 4378 -1 4913 ;208 2853 -1 4005 3964 -1 9828 -1 4786 7602 ;-1 -1 -1 -1 -1 329 7985 -1 -1 28 ;-1 -1 -1 -1 4433 4085 9221 6038 7258 3834 ;9013 -1 5560 2745 5061 -1 3495 -1 -1 -1 ;2760 6565 7246 6924 -1 2700 -1 -1 4588 -1 ;9953 4344 8740 -1 152 8435 6756 3520 3078 9535 ;9930 9193 2399 246 4552 5468 -1 -1 -1 -1 ];
vexp=35734;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
25
Pass
 
%%
zee=[4 0 7 0];
zm=[919 3728 6660 -1 5410 4513 8419 6070 482 6421 ;111 -1 4828 8468 -1 3201 -1 4659 -1 4738 ;-1 361 8017 4673 8999 4687 852 -1 7981 -1 ;-1 1520 9557 5945 8837 3767 9832 9775 -1 9935 ;5796 9072 -1 -1 392 341 3808 4109 4905 -1 ;9614 -1 8450 977 247 2107 7400 6786 -1 -1 ;4341 -1 4733 2658 -1 6043 8860 1838 6912 523 ;2432 4045 -1 -1 5361 895 -1 3895 1321 6672 ;2026 5899 1723 1201 1691 9580 1387 -1 -1 1689 ];
vexp=22183;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
26
Pass
 
%%
zee=[1 2 2 1];
zm=[-1 -1 -1 -1 7201 7409 -1 9659 2860 9119 ;-1 9984 7612 9104 607 -1 9877 -1 2932 1986 ;5397 1618 2580 -1 69 2446 -1 -1 1160 7900 ;-1 9269 -1 6227 5896 200 5386 8138 -1 8909 ;7316 1699 -1 3087 -1 -1 -1 4699 -1 3670 ;8428 9133 3314 3461 4829 6483 7198 8227 8516 5217 ;325 54 8642 8561 -1 8582 -1 6678 3552 -1 ;7012 3037 6339 9407 6933 -1 9350 1820 5500 -1 ];
vexp=19214;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
27
Pass
 
%%
zee=[0 0 9 9];
zm=[1505 3402 2754 9713 414 2610 2749 8975 8948 1456 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 8381 ;2838 4740 4009 1596 442 4853 3416 6467 6705 1640 ;9059 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;7197 4825 212 7826 2129 6298 2502 1979 9061 4006 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 1733 ;1814 3718 8498 4423 2818 7472 9722 625 2204 8912 ;5365 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;6212 507 5806 7416 274 8624 4120 1914 7683 7669 ;3090 4246 1846 5219 6895 4347 3549 5955 8352 5281 ];
vexp=259550;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
28
Pass
 
%%
zee=[0 0 9 0];
zm=[4120 8421 130 8543 1238 7601 4616 1863 6156 3527 ;3579 8719 386 9384 6135 7011 4359 6606 5276 8393 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 626 ;8366 2638 2471 3584 5884 6817 3484 8190 5168 8765 ;2310 9940 5246 7204 1178 2847 1819 9392 5354 1698 ;2970 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;4073 8435 8705 6559 1797 3063 9516 7073 1456 142 ;1790 445 2612 1725 6329 9429 5208 4518 948 3972 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 6827 ;888 5570 382 8417 4768 2201 7808 121 250 7129 ];
vexp=243332;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
29
Pass
 
%%
zee=[9 0 0 9];
zm=[4193 5036 5833 7103 6832 8895 6619 3904 350 6760 ;2045 7147 9371 3769 3475 8799 8977 4344 9747 9300 ;7523 6986 4869 7904 5402 9636 104 3209 9757 6705 ;337 301 1740 6169 7404 8572 1415 4022 8827 8117 ;7133 872 5263 6503 4640 8737 1654 3616 9432 7752 ;9268 6954 4737 4136 4858 138 3772 1313 9698 3528 ;8018 6386 180 6109 8906 7583 1032 320 7956 9859 ;8436 5088 7082 50 1591 8073 5138 9596 8041 4570 ;7347 7308 1523 2083 1443 6380 8572 1566 4045 4621 ;1445 2062 1006 1625 4522 9911 5559 5554 230 3515 ];
vexp=137679;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))

                    
30
Pass
 
%%
zee=[3 7 3 6];
zm=[-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 -1 -1 -1 -1 2896 5067 -1 -1 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ;-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ];
vexp=7963;
v=Dragon_CH(zee,zm);
assert(isequal(v,vexp))
toc
Elapsed time is 0.078465 seconds.