Cody

Solution 160810

Submitted on 12 Nov 2012 by José-Luis
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))

A = Columns 1 through 3 [1x9 double] [1x8 double] [1x7 double] Columns 4 through 6 [1x6 double] [1x5 double] [1x4 double] Columns 7 through 9 [1x3 double] [1x2 double] [35]

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))

A = Columns 1 through 3 [1x9 double] [1x8 double] [1x7 double] Columns 4 through 6 [1x6 double] [1x5 double] [1x4 double] Columns 7 through 9 [1x3 double] [1x2 double] [3778]

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

A = [1x3 double] [1x2 double] [20]

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

A = [1x4 double] [1x3 double] [1x2 double] [1001]

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

A = Columns 1 through 3 [1x1000 double] [1x999 double] [1x998 double] Columns 4 through 6 [1x997 double] [1x996 double] [1x995 double] Columns 7 through 9 [1x994 double] [1x993 double] [1x992 double] Columns 10 through 12 [1x991 double] [1x990 double] [1x989 double] Columns 13 through 15 [1x988 double] [1x987 double] [1x986 double] Columns 16 through 18 [1x985 double] [1x984 double] [1x983 double] Columns 19 through 21 [1x982 double] [1x981 double] [1x980 double] Columns 22 through 24 [1x979 double] [1x978 double] [1x977 double] Columns 25 through 27 [1x976 double] [1x975 double] [1x974 double] Columns 28 through 30 [1x973 double] [1x972 double] [1x971 double] Columns 31 through 33 [1x970 double] [1x969 double] [1x968 double] Columns 34 through 36 [1x967 double] [1x966 double] [1x965 double] Columns 37 through 39 [1x964 double] [1x963 double] [1x962 double] Columns 40 through 42 [1x961 double] [1x960 double] [1x959 double] Columns 43 through 45 [1x958 double] [1x957 double] [1x956 double] Columns 46 through 48 [1x955 double] [1x954 double] [1x953 double] Columns 49 through 51 [1x952 double] [1x951 double] [1x950 double] Columns 52 through 54 [1x949 double] [1x948 double] [1x947 double] Columns 55 through 57 [1x946 double] [1x945 double] [1x944 double] Columns 58 through 60 [1x943 double] [1x942 double] [1x941 double] Columns 61 through 63 [1x940 double] [1x939 double] [1x938 double] Columns 64 through 66 [1x937 double] [1x936 double] [1x935 double] Columns 67 through 69 [1x934 double] [1x933 double] [1x932 double] Columns 70 through 72 [1x931 double] [1x930 double] [1x929 double] Columns 73 through 75 [1x928 double] [1x927 double] [1x926 double] Columns 76 through 78 [1x925 double] [1x924 double] [1x923 double] Columns 79 through 81 [1x922 double] [1x921 double] [1x920 double] Columns 82 through 84 [1x919 double] [1x918 double] [1x917 double] Columns 85 through 87 [1x916 double] [1x915 double] [1x914 double] Columns 88 through 90 [1x913 double] [1x912 double] [1x911 double] Columns 91 through 93 [1x910 double] [1x909 double] [1x908 double] Columns 94 through 96 [1x907 double] [1x906 double] [1x905 double] Columns 97 through 99 [1x904 double] [1x903 double] [1x902 double] Columns 100 through 102 [1x901 double] [1x900 double] [1x899 double] Columns 103 through 105 [1x898 double] [1x897 double] [1x896 double] Columns 106 through 108 [1x895 double] [1x894 double] [1x893 double] Columns 109 through 111 [1x892 double] [1x891 double] [1x890 double] Columns 112 through 114 [1x889 double] [1x888 double] [1x887 double] Columns 115 through 117 [1x886 double] [1x885 double] [1x884 double] Columns 118 through 120 [1x883 double] [1x882 double] [1x881 double] Columns 121 through 123 [1x880 double] [1x879 double] [1x878 double] Columns 124 through 126 [1x877 double] [1x876 double] [1x875 double] Columns 127 through 129 [1x874 double] [1x873 double] [1x872 double] Columns 130 through 132 [1x871 double] [1x870 double] [1x869 double] Columns 133 through 135 [1x868 double] [1x867 double] [1x866 double] Columns 136 through 138 [1x865 double] [1x864 double] [1x863 double] Columns 139 through 141 [1x862 double] [1x861 double] [1x860 double] Columns 142 through 144 [1x859 double] [1x858 double] [1x857 double] Columns 145 through 147 [1x856 double] [1x855 double] [1x854 double] Columns 148 through 150 [1x853 double] [1x852 double] [1x851 double] Columns 151 through 153 [1x850 double] [1x849 double] [1x848 double] Columns 154 through 156 [1x847 double] [1x846 double] [1x845 double] Columns 157 through 159 [1x844 double] [1x843 double] [1x842 double] Columns 160 through 162 [1x841 double] [1x840 double] [1x839 double] Columns 163 through 165 [1x838 double] [1x837 double] [1x836 double] Columns 166 through 168 [1x835 double] [1x834 double] [1x833 double] Columns 169 through 171 [1x832 double] [1x831 double] [1x830 double] Columns 172 through 174 [1x829 double] [1x828 double] [1x827 double] Columns 175 through 177 [1x826 double] [1x825 double] [1x824 double] Columns 178 through 180 [1x823 double] [1x822 double] [1x821 double] Columns 181 through 183 [1x820 double] [1x819 double] [1x818 double] Columns 184 through 186 [1x817 double] [1x816 double] [1x815 double] Columns 187 through 189 [1x814 double] [1x813 double] [1x812 double] Columns 190 through 192 [1x811 double] [1x810 double] [1x809 double] Columns 193 through 195 [1x808 double] [1x807 double] [1x806 double] Columns 196 through 198 [1x805 double] [1x804 double] [1x803 double] Columns 199 through 201 [1x802 double] [1x801 double] [1x800 double] Columns 202 through 204 [1x799 double] [1x798 double] [1x797 double] Columns 205 through 207 [1x796 double] [1x795 double] [1x794 double] Columns 208 through 210 [1x793 double] [1x792 double] [1x791 double] Columns 211 through 213 [1x790 double] [1x789 double] [1x788 double] Columns 214 through 216 [1x787 double] [1x786 double] [1x785 double] Columns 217 through 219 [1x784 double] [1x783 double] [1x782 double] Columns 220 through 222 [1x781 double] [1x780 double] [1x779 double] Columns 223 through 225 [1x778 double] [1x777 double] [1x776 double] Columns 226 through 228 [1x775 double] [1x774 double] [1x773 double] Columns 229 through 231 [1x772 double] [1x771 double] [1x770 double] Columns 232 through 234 [1x769 double] [1x768 double] [1x767 double] Columns 235 through 237 [1x766 double] [1x765 double] [1x764 double] Columns 238 through 240 [1x763 double] [1x762 double] [1x761 double] Columns 241 through 243 [1x760 double] [1x759 double] [1x758 double] Columns 244 through 246 [1x757 double] [1x756 double] [1x755 double] Columns 247 through 249 [1x754 double] [1x753 double] [1x752 double] Columns 250 through 252 [1x751 double] [1x750 double] [1x749 double] Columns 253 through 255 [1x748 double] [1x747 double] [1x746 double] Columns 256 through 258 [1x745 double] [1x744 double] [1x743 double] Columns 259 through 261 [1x742 double] [1x741 double] [1x740 double] Columns 262 through 264 [1x739 double] [1x738 double] [1x737 double] Columns 265 through 267 [1x736 double] [1x735 double] [1x734 double] Columns 268 through 270 [1x733 double] [1x732 double] [1x731 double] Columns 271 through 273 [1x730 double] [1x729 double] [1x728 double] Columns 274 through 276 [1x727 double] [1x726 double] [1x725 double] Columns 277 through 279 [1x724 double] [1x723 double] [1x722 double] Columns 280 through 282 [1x721 double] [1x720 double] [1x719 double] Columns 283 through 285 [1x718 double] [1x717 double] [1x716 double] Columns 286 through 288 [1x715 double] [1x714 double] [1x713 double] Columns 289 through 291 [1x712 double] [1x711 double] [1x710 double] Columns 292 through 294 [1x709 double] [1x708 double] [1x707 double] Columns 295 through 297 [1x706 double] [1x705 double] [1x704 double] Columns 298 through 300 [1x703 double] [1x702 double] [1x701 double] Columns 301 through 303 [1x700 double] [1x699 double] [1x698 double] Columns 304 through 306 [1x697 double] [1x696 double] [1x695 double] Columns 307 through 309 [1x694 double] [1x693 double] [1x692 double] Columns 310 through 312 [1x691 double] [1x690 double] [1x689 double] Columns 313 through 315 [1x688 double] [1x687 double] [1x686 double] Columns 316 through 318 [1x685 double] [1x684 double] [1x683 double] Columns 319 through 321 [1x682 double] [1x681 double] [1x680 double] Columns 322 through 324 [1x679 double] [1x678 double] [1x677 double] Columns 325 through 327 [1x676 double] [1x675 double] [1x674 double] Columns 328 through 330 [1x673 double] [1x672 double] [1x671 double] Columns 331 through 333 [1x670 double] [1x669 double] [1x668 double] Columns 334 through 336 [1x667 double] [1x666 double] [1x665 double] Columns 337 through 339 [1x664 double] [1x663 double] [1x662 double] Columns 340 through 342 [1x661 double] [1x660 double] [1x659 double] Columns 343 through 345 [1x658 double] [1x657 double] [1x656 double] Columns 346 through 348 [1x655 double] [1x654 double] [1x653 double] Columns 349 through 351 [1x652 double] [1x651 double] [1x650 double] Columns 352 through 354 [1x649 double] [1x648 double] [1x647 double] Columns 355 through 357 [1x646 double] [1x645 double] [1x644 double] Columns 358 through 360 [1x643 double] [1x642 double] [1x641 double] Columns 361 through 363 [1x640 double] [1x639 double] [1x638 double] Columns 364 through 366 [1x637 double] [1x636 double] [1x635 double] Columns 367 through 369 [1x634 double] [1x633 double] [1x632 double] Columns 370 through 372 [1x631 double] [1x630 double] [1x629 double] Columns 373 through ...

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

A = [1x4 double] [1x3 double] [1x2 double] [100]

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

A = [1x4 double] [1x3 double] [1x2 double] [50600]