Cody

Solution 13616

Submitted on 29 Jan 2012 by A Millo
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
%% A = [30 46 16 -46 35 44 18 26 25 -10]; correct = [8 9]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

y = -46 -10 16 18 25 26 30 35 44 46 i = 4 10 3 7 9 8 1 5 6 2 y = 1 2 2 4 5 7 9 26 36 j = 5 3 9 6 7 4 8 2 1 y = 8 9 index1 = 8 index2 = 9

2   Pass
%% A = [1555 -3288 2061 -4681 -2230 -4538 -4028 3235 1949 -1829]; correct = [3 9]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

y = Columns 1 through 5 -4681 -4538 -4028 -3288 -2230 Columns 6 through 10 -1829 1555 1949 2061 3235 i = 4 6 7 2 5 10 1 9 3 8 y = Columns 1 through 5 112 143 394 401 510 Columns 6 through 9 740 1058 1174 3384 j = 8 1 7 5 2 3 4 9 6 y = 3 9 index1 = 3 index2 = 9

3   Pass
%% A = [-1 1 10 -10]; correct = [1 2]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

y = -10 -1 1 10 i = 4 1 2 3 y = 2 9 9 j = 2 1 3 y = 1 2 index1 = 1 index2 = 2

4   Pass
%% A = [0 1000 -2000 1001 0]; correct = [1 5]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

y = -2000 0 0 1000 1001 i = 3 1 5 2 4 y = 0 1 1000 2000 j = 2 4 3 1 y = 1 5 index1 = 1 index2 = 5

5   Pass
%% A = [1:1000 0.5]; correct = [1 1001]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

y = 1.0e+03 * Columns 1 through 6 0.0005 0.0010 0.0020 0.0030 0.0040 0.0050 Columns 7 through 12 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 Columns 13 through 18 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 Columns 19 through 24 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 Columns 25 through 30 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 Columns 31 through 36 0.0300 0.0310 0.0320 0.0330 0.0340 0.0350 Columns 37 through 42 0.0360 0.0370 0.0380 0.0390 0.0400 0.0410 Columns 43 through 48 0.0420 0.0430 0.0440 0.0450 0.0460 0.0470 Columns 49 through 54 0.0480 0.0490 0.0500 0.0510 0.0520 0.0530 Columns 55 through 60 0.0540 0.0550 0.0560 0.0570 0.0580 0.0590 Columns 61 through 66 0.0600 0.0610 0.0620 0.0630 0.0640 0.0650 Columns 67 through 72 0.0660 0.0670 0.0680 0.0690 0.0700 0.0710 Columns 73 through 78 0.0720 0.0730 0.0740 0.0750 0.0760 0.0770 Columns 79 through 84 0.0780 0.0790 0.0800 0.0810 0.0820 0.0830 Columns 85 through 90 0.0840 0.0850 0.0860 0.0870 0.0880 0.0890 Columns 91 through 96 0.0900 0.0910 0.0920 0.0930 0.0940 0.0950 Columns 97 through 102 0.0960 0.0970 0.0980 0.0990 0.1000 0.1010 Columns 103 through 108 0.1020 0.1030 0.1040 0.1050 0.1060 0.1070 Columns 109 through 114 0.1080 0.1090 0.1100 0.1110 0.1120 0.1130 Columns 115 through 120 0.1140 0.1150 0.1160 0.1170 0.1180 0.1190 Columns 121 through 126 0.1200 0.1210 0.1220 0.1230 0.1240 0.1250 Columns 127 through 132 0.1260 0.1270 0.1280 0.1290 0.1300 0.1310 Columns 133 through 138 0.1320 0.1330 0.1340 0.1350 0.1360 0.1370 Columns 139 through 144 0.1380 0.1390 0.1400 0.1410 0.1420 0.1430 Columns 145 through 150 0.1440 0.1450 0.1460 0.1470 0.1480 0.1490 Columns 151 through 156 0.1500 0.1510 0.1520 0.1530 0.1540 0.1550 Columns 157 through 162 0.1560 0.1570 0.1580 0.1590 0.1600 0.1610 Columns 163 through 168 0.1620 0.1630 0.1640 0.1650 0.1660 0.1670 Columns 169 through 174 0.1680 0.1690 0.1700 0.1710 0.1720 0.1730 Columns 175 through 180 0.1740 0.1750 0.1760 0.1770 0.1780 0.1790 Columns 181 through 186 0.1800 0.1810 0.1820 0.1830 0.1840 0.1850 Columns 187 through 192 0.1860 0.1870 0.1880 0.1890 0.1900 0.1910 Columns 193 through 198 0.1920 0.1930 0.1940 0.1950 0.1960 0.1970 Columns 199 through 204 0.1980 0.1990 0.2000 0.2010 0.2020 0.2030 Columns 205 through 210 0.2040 0.2050 0.2060 0.2070 0.2080 0.2090 Columns 211 through 216 0.2100 0.2110 0.2120 0.2130 0.2140 0.2150 Columns 217 through 222 0.2160 0.2170 0.2180 0.2190 0.2200 0.2210 Columns 223 through 228 0.2220 0.2230 0.2240 0.2250 0.2260 0.2270 Columns 229 through 234 0.2280 0.2290 0.2300 0.2310 0.2320 0.2330 Columns 235 through 240 0.2340 0.2350 0.2360 0.2370 0.2380 0.2390 Columns 241 through 246 0.2400 0.2410 0.2420 0.2430 0.2440 0.2450 Columns 247 through 252 0.2460 0.2470 0.2480 0.2490 0.2500 0.2510 Columns 253 through 258 0.2520 0.2530 0.2540 0.2550 0.2560 0.2570 Columns 259 through 264 0.2580 0.2590 0.2600 0.2610 0.2620 0.2630 Columns 265 through 270 0.2640 0.2650 0.2660 0.2670 0.2680 0.2690 Columns 271 through 276 0.2700 0.2710 0.2720 0.2730 0.2740 0.2750 Columns 277 through 282 0.2760 0.2770 0.2780 0.2790 0.2800 0.2810 Columns 283 through 288 0.2820 0.2830 0.2840 0.2850 0.2860 0.2870 Columns 289 through 294 0.2880 0.2890 0.2900 0.2910 0.2920 0.2930 Columns 295 through 300 0.2940 0.2950 0.2960 0.2970 0.2980 0.2990 Columns 301 through 306 0.3000 0.3010 0.3020 0.3030 0.3040 0.3050 Columns 307 through 312 0.3060 0.3070 0.3080 0.3090 0.3100 0.3110 Columns 313 through 318 0.3120 0.3130 0.3140 0.3150 0.3160 0.3170 Columns 319 through 324 0.3180 0.3190 0.3200 0.3210 0.3220 0.3230 Columns 325 through 330 0.3240 0.3250 0.3260 0.3270 0.3280 0.3290 Columns 331 through 336 0.3300 0.3310 0.3320 0.3330 0.3340 0.3350 Columns 337 through 342 0.3360 0.3370 0.3380 0.3390 0.3400 0.3410 Columns 343 through 348 0.3420 0.3430 0.3440 0.3450 0.3460 0.3470 Columns 349 through 354 0.3480 0.3490 0.3500 0.3510 0.3520 0.3530 Columns 355 through 360 0.3540 0.3550 0.3560 0.3570 0.3580 0.3590 Columns 361 through 366 0.3600 0.3610 0.3620 0.3630 0.3640 0.3650 Columns 367 through 372 0.3660 0.3670 0.3680 0.3690 0.3700 0.3710 Columns 373 through 378 0.3720 0.3730 0.3740 0.3750 0.3760 0.3770 Columns 379 through 384 0.3780 0.3790 0.3800 0.3810 0.3820 0.3830 Columns 385 through 390 0.3840 0.3850 0.3860 0.3870 0.3880 0.3890 Columns 391 through 396 0.3900 0.3910 0.3920 0.3930 0.3940 0.3950 Columns 397 through 402 0.3960 0.3970 0.3980 0.3990 0.4000 0.4010 Columns 403 through 408 0.4020 0.4030 0.4040 0.4050 0.4060 0.4070 Columns 409 through 414 0.4080 0.4090 0.4100 0.4110 0.4120 0.4130 Columns 415 through 420 0.4140 0.4150 0.4160 0.4170 0.4180 0.4190 Columns 421 through 426 0.4200 0.4210 0.4220 0.4230 0.4240 0.4250 Columns 427 through 432 0.4260 0.4270 0.4280 0.4290 0.4300 0.4310 Columns 433 through 438 0.4320 0.4330 0.4340 0.4350 0.4360 0.4370 Columns 439 through 444 0.4380 0.4390 0.4400 0.4410 0.4420 0.4430 Columns 445 through 450 0.4440 0.4450 0.4460 0.4470 0.4480 0.4490 Columns 451 through 456 0.4500 0.4510 0.4520 0.4530 0.4540 0.4550 Columns 457 through 462 0.4560 0.4570 0.4580 0.4590 0.4600 0.4610 Columns 463 through 468 0.4620 0.4630 0.4640 0.4650 0.4660 0.4670 Columns 469 through 474 0.4680 0.4690 0.4700 0.4710 0.4720 0.4730 Columns 475 through 480 0.4740 0.4750 0.4760 0.4770 0.4780 0.4790 Columns 481 through 486 0.4800 0.4810 0.4820 0.4830 0.4840 0.4850 Columns 487 through 492 0.4860 0.4870 0.4880 0.4890 0.4900 0.4910 Columns 493 through 498 0.4920 0.4930 0.4940 0.4950 0.4960 0.4970 Columns 499 through 504 0.4980 0.4990 0.5000 0.5010 0.5020 0.5030 Columns 505 through 510 0.5040 0.5050 0.5060 0.5070 0.5080 0.5090 Columns 511 through 516 0.5100 0.5110 0.5120 0.5130 0.5140 0.5150 Columns 517 through 522 0.5160 0.5170 0.5180 0.5190 0.5200 0.5210 Columns 523 through 528 0.5220 0.5230 0.5240 0.5250 0.5260 0.5270 Columns 529 through 534 0.5280 0.5290 0.5300 0.5310 0.5320 0.5330 Columns 535 through 540 0.5340 0.5350 0.5360 0.5370 0.5380 0.5390 Columns 541 through 546 0.5400 0.5410 0.5420 0.5430 0.5440 0.5450 Columns 547 through 552 0.5460 0.5470 0.5480 0.5490 0.5500 0.5510 Columns 553 through 558 0.5520 0.5530 0.5540 0.5550 0.5560 0.5570 Columns 559 through 564 0.5580 0.5590 0.5600 0.5610 0.5620 0.5630 Columns 565 through 570 0.5640 0.5650 0.5660 0.5670 0.5680 0.5690 Columns 571 through 576 0.5700 0.5710 0.5720 0.5730 0.5740 0.5750 Columns 577 through 582 0.5760 0.5770 0.5780 0.5790 0.5800 0.5810 Columns 583 through 588 0.5820 0.5830 0.5840 0.5850 0.5860 0.5870 Columns 589 through 594 0.5880 0.5890 0.5900 0.5910 0.5920 0.5930 Columns 595 through 600 0.5940 0.5950 0.5960 0.5970 0.5980 0.5990 Columns 601 through 606 0.6000 0.6010 0.6020 0.6030 0.6040 0.6050 Columns 607 through 612 0.6060 0.6070 0.6080 0.6090 0.6100 0.6110 Columns 613 through 618 0.6120 0.6130 0.6140 0.6150 0.6160 0.6170 Columns 619 through 624 0.6180 0.6190 0.6200 0.6210 0.6220 0.6230 Columns 625 through 630 0.6240 0.6250 0.6260 0.6270 0.6280 0.6290 Columns 631 through 636 0.6300 0.6310 0.6320 0.6330 0.6340 0.6350 Columns 637 through 642 0.6360 0.6370 0.6380 0.6390 0.6400 0.6410 Columns 643 through 648 0.6420 0.6430 0.6440 0.6450 0.6460 0.6470 Columns 649 through 654 0.6480 0.6490 0.6500 0.6510 0.6520 0.6530 Columns 655 through 660 0.6540 0.6550 0.6560 0.6570 0.6580 0.6590 Columns 661 through 666 0.6600 0.6610 0.6620 0.6630 0.6640 0.6650 Columns 667 through 672 0.6660 0.6670 0.6680 0.6690 0.6700 0.6710 Columns 673 through 678 0.6720 0.6730 0.6740 0.6750 0.6760 0.6770 Columns 679 through 684 0.6780 0.6790 0.6800 0.6810 0.6820 0.6830 Columns 685 through 690 0.6840 0.6850 0.6860 0.6870 0.6880 0.6890 Columns 691...

6   Pass
%% % Area codes A = [847 217 508 312 212]; correct = [2 5]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

y = 212 217 312 508 847 i = 5 2 4 3 1 y = 5 95 196 339 j = 1 2 3 4 y = 2 5 index1 = 2 index2 = 5

7   Pass
%% % Zip codes A = [60048 61802 01702 60601 10001]; correct = [1 4]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

y = 1702 10001 60048 60601 61802 i = 3 5 1 4 2 y = 553 1201 8299 50047 j = 3 4 1 2 y = 1 4 index1 = 1 index2 = 4