Cody

Solution 1529287

Submitted on 15 May 2018 by Varun Garg
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))

min = 10000 x = 16 min = 16 index2 = 2 index1 = 1 x = 14 min = 14 index2 = 3 index1 = 1 x = 76 x = 5 min = 5 index2 = 5 index1 = 1 x = 14 x = 12 x = 4 min = 4 index2 = 8 index1 = 1 x = 5 x = 40 x = 30 x = 92 x = 11 x = 2 min = 2 index2 = 6 index1 = 2 x = 28 x = 20 x = 21 x = 56 x = 62 x = 19 x = 28 x = 2 x = 10 x = 9 x = 26 x = 81 x = 90 x = 64 x = 72 x = 71 x = 36 x = 9 x = 17 x = 9 x = 10 x = 45 x = 26 x = 18 x = 19 x = 54 x = 8 x = 7 x = 28 x = 1 min = 1 index2 = 9 index1 = 8 x = 36 x = 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))

min = 10000 x = 4843 min = 4843 index2 = 2 index1 = 1 x = 506 min = 506 index2 = 3 index1 = 1 x = 6236 x = 3785 x = 6093 x = 5583 x = 1680 x = 394 min = 394 index2 = 9 index1 = 1 x = 3384 x = 5349 x = 1393 x = 1058 x = 1250 x = 740 x = 6523 x = 5237 x = 1459 x = 6742 x = 4291 x = 6599 x = 6089 x = 1174 x = 112 min = 112 index2 = 9 index1 = 3 x = 3890 x = 2451 x = 143 x = 653 x = 7916 x = 6630 x = 2852 x = 2308 x = 1798 x = 5465 x = 4179 x = 401 x = 510 x = 7773 x = 6487 x = 2709 x = 7263 x = 5977 x = 2199 x = 1286 x = 5064 x = 3778

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

min = 10000 x = 2 min = 2 index2 = 2 index1 = 1 x = 11 x = 9 x = 9 x = 11 x = 20

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

min = 10000 x = 1000 min = 1000 index2 = 2 index1 = 1 x = 2000 x = 1001 x = 0 min = 0 index2 = 5 index1 = 1 x = 3000 x = 1 x = 1000 x = 3001 x = 2000 x = 1001

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

min = 10000 x = 1 min = 1 index2 = 2 index1 = 1 x = 2 x = 3 x = 4 x = 5 x = 6 x = 7 x = 8 x = 9 x = 10 x = 11 x = 12 x = 13 x = 14 x = 15 x = 16 x = 17 x = 18 x = 19 x = 20 x = 21 x = 22 x = 23 x = 24 x = 25 x = 26 x = 27 x = 28 x = 29 x = 30 x = 31 x = 32 x = 33 x = 34 x = 35 x = 36 x = 37 x = 38 x = 39 x = 40 x = 41 x = 42 x = 43 x = 44 x = 45 x = 46 x = 47 x = 48 x = 49 x = 50 x = 51 x = 52 x = 53 x = 54 x = 55 x = 56 x = 57 x = 58 x = 59 x = 60 x = 61 x = 62 x = 63 x = 64 x = 65 x = 66 x = 67 x = 68 x = 69 x = 70 x = 71 x = 72 x = 73 x = 74 x = 75 x = 76 x = 77 x = 78 x = 79 x = 80 x = 81 x = 82 x = 83 x = 84 x = 85 x = 86 x = 87 x = 88 x = 89 x = 90 x = 91 x = 92 x = 93 x = 94 x = 95 x = 96 x = 97 x = 98 x = 99 x = 100 x = 101 x = 102 x = 103 x = 104 x = 105 x = 106 x = 107 x = 108 x = 109 x = 110 x = 111 x = 112 x = 113 x = 114 x = 115 x = 116 x = 117 x = 118 x = 119 x = 120 x = 121 x = 122 x = 123 x = 124 x = 125 x = 126 x = 127 x = 128 x = 129 x = 130 x = 131 x = 132 x = 133 x = 134 x = 135 x = 136 x = 137 x = 138 x = 139 x = 140 x = 141 x = 142 x = 143 x = 144 x = 145 x = 146 x = 147 x = 148 x = 149 x = 150 x = 151 x = 152 x = 153 x = 154 x = 155 x = 156 x = 157 x = 158 x = 159 x = 160 x = 161 x = 162 x = 163 x = 164 x = 165 x = 166 x = 167 x = 168 x = 169 x = 170 x = 171 x = 172 x = 173 x = 174 x = 175 x = 176 x = 177 x = 178 x = 179 x = 180 x = 181 x = 182 x = 183 x = 184 x = 185 x = 186 x = 187 x = 188 x = 189 x = 190 x = 191 x = 192 x = 193 x = 194 x = 195 x = 196 x = 197 x = 198 x = 199 x = 200 x = 201 x = 202 x = 203 x = 204 x = 205 x = 206 x = 207 x = 208 x = 209 x = 210 x = 211 x = 212 x = 213 x = 214 x = 215 x = 216 x = 217 x = 218 x = 219 x = 220 x = 221 x = 222 x = 223 x = 224 x = 225 x = 226 x = 227 x = 228 x = 229 x = 230 x = 231 x = 232 x = 233 x = 234 x = 235 x = 236 x = 237 x = 238 x = 239 x = 240 x = 241 x = 242 x = 243 x = 244 x = 245 x = 246 x = 247 x = 248 x = 249 x = 250 x = 251 x = 252 x = 253 x = 254 x = 255 x = 256 x = 257 x = 258 x = 259 x = 260 x = 261 x = 262 x = 263 x = 264 x = 265 x = 266 x = 267 x = 268 x = 269 x = 270 x = 271 x = 272 x = 273 x = 274 x = 275 x = 276 x = 277 x = 278 x = 279 x = 280 x = 281 x = 282 x = 283 x = 284 x = 285 x = 286 x = 287 x = 288 x = 289 x = 290 x = 291 x = 292 x = 293 x = 294 x = 295 x = 296 x = 297 x = 298 x = 299 x = 300 x = 301 x = 302 x = 303 x = 304 x = 305 x = 306 x = 307 x = 308 x = 309 x = 310 x = 311 x = 312 x = 313 x = 314 x = 315 x = 316 x = 317 x = 318 x = 319 x = 320 x = 321 x = 322 x = 323 x = 324 x = 325 x = 326 x = 327 x = 328 x = 329 x = 330 x = 331 x = 332 x = 333 x = 334 x = 335 x = 336 x = 337 x = 338 x = 339 x = 340 x = 341 x = 342 x = 343 x = 344 x = 345 x = 346 x = 347 x = 348 x = 349 x = 350 x = 351 x = 352 x = 353 x = 354 x = 355 x = 356 x = 357 x = 358 x = 359 x = 360 x = 361 x = 362 x = 363 x = 364 x = 365 x = 366 x = 367 x = 368 x = 369 x = 370 x = 371 x = 372 x = 373 x = 374 x = 375 x = 376 x = 377 x = 378 x = 379 x = 380 x = 381 x = 382 x = 383 x = 384 x = 385 x = 386 x = 387 x = 388 x = 389 x = 390 x = 391 x = 392 x = 393 x = 394 x = 395 x = 396 x = 397 x = 398 x = 399 x = 400 x = 401 x = 402 x = 403 x = 404 x = 405 x = 406 x = 407 x = 408 x = 409 x = 410 x = 411 x = 412 x = 413 x = 414 x = 415 x = 416 x = 417 x = 418 x = 419 x = 420 x = 421 x = 422 x = 423 x = 424 x = 425 x = 426 x = 427 x = 428 x = 429 x = 430 x = 431 x = 432 x = 433 x = 434 x = 435 x = 436 x = 437 x = 438 x = 439 x = 440 x = 441 x = 442 x = 443 x = 444 x = 445 x = 446 x = 447 x = 448 x = 449 x = 450 x = 451 x = 452 x = 453 x = 454 x = 455 x = 456 x = 457 x = 458 x = 459 x = 460 x = 461 x = 462 x = 463 x = 464 x = 465 x = 466 x = 467 x = 468 x = 469 x = 470 x = 471 x = 472 x = 473 x = 474 x = 475 x = 476 x = 477 x = 478 x = 479 x = 480 x = 481 x = 482 x = 483 x = 484 x = 485 x = 486 x = 487 x = 488 x = 489 x = 490 x = 491 x = 492 x = 493 x = 494 x = 495 x = 496 x = 497 x = 498 x = 499 x = 500 x = 501 x = 502 x = 503 x = 504 x = 505 x = 506 x = 507 x = 508 x = 509 x = 510 x = 511 x = 512 x = 513 x = 514 x = 515 x = 516 x = 517 x = 518 x = 519 x = 520 x = 521 x = 522 x = 523 x = 524 x = 525 x = 526 x = 527 x = 528 x = 529 x = 530 x = 531 x = 532 x = 533 x = 534 x = 535 x = 536 x = 537 x = 538 x = 539 x = 540 x = 541 x = 542 x = 543 x = 544 x = 545 x = 546 x = 547 x = 548 x = 549 x = 550 x = 551 x = 552 x = 553 x = 554 x = 555 x = 556 x = 557 x = 558 x = 559 x = 560 x = 561 x = 562 x = 563 x = 564 x = 565 x = 566 x = 567 x = 568 x = 569 x = 570 x = 571 x = 572 x = 573 x = 574 x = 575 x = 576 x = 577 x = 578 x = 579 x = 580 x = 581 x = 582 x = 583 x = 584 x = 585 x = 586 x = 587 x = 588 x = 589 x = 590 x = 591 x = 592 x = 593 x = 594 x = 595 x = 596 x = 597 x = 598 x = 599 x = 600 x = 601 x = 602 x = 603 x = 604 x = 605 x = 606 x = 607 x = 608 x = 609 x = 610 x = 611 x = 612 x = 613 x = 614 x = 615 x = 616 x = 617 x = 618 x = 619 x = 620 x = 621 x = 622 x = 623 x = 624 x = 625 x = 626 x = 627 x = 628 x = 629 x = 630 x = 631 x = 632 x = 633 x = 634 x = 635 x = 636 x = 637 x = 638 x = 639 x = 640 x = 641 x = 642 x = 643 x = 644 x = 645 x = 646 x = 647 x = 648 x = 649 x = 650 x = 651 x = 652 x = 653 x = 654 x = 655 x = 656 x = 657 x = 658 x = 659 x = 660 x = 661 x = 662 x = 663 x = 664 x = 665 x = 666 x = 667 x = 668 x = 669 x = 670 x = 671 x = 672 x = 673 x = 674 x = 675 x = 676 x = 677 x = 678 x = 679 x = 680 x = 681 x = 682 x = 683 x = 684 x = 685 x = 686 x = 687 x = 688 x = 689 x = 690 x = 691 x = 692 x = 693 x = 694 x = 695 x = 696 x = 697 x = 698 x = 699 x = 700 x = 701 x = 702 x = 703 x = 704 x = 705 x = 706 x = 707 x = 708 x = 709 ...

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

min = 10000 x = 630 min = 630 index2 = 2 index1 = 1 x = 339 min = 339 index2 = 3 index1 = 1 x = 535 x = 635 x = 291 min = 291 index2 = 3 index1 = 2 x = 95 min = 95 index2 = 4 index1 = 2 x = 5 min = 5 index2 = 5 index1 = 2 x = 196 x = 296 x = 100

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

min = 10000 x = 1754 min = 1754 index2 = 2 index1 = 1 x = 58346 x = 553 min = 553 index2 = 4 index1 = 1 x = 50047 x = 60100 x = 1201 x = 51801 x = 58899 x = 8299 x = 50600