Cody

# Problem 42989. Find unique number in input

Solution 2156789

Submitted on 11 Mar 2020 by Asif Newaz
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 = []; y_correct = 0; assert(isequal(uniqueNum(x),y_correct))

a = 0×1 empty double column vector b = []

2   Pass
x = [1 7 7 1 7 6 3 7 6 7 3]; y_correct = 7; assert(isequal(uniqueNum(x),y_correct))

a = 1 3 6 7 b = 2 2 2 5

3   Pass
x = [21 62 85 21 85 13 49 5 56 20 62 37 4 4 63 49 56 20 63 37 5 ]; y_correct = 13; assert(isequal(uniqueNum(x),y_correct))

a = 4 5 13 20 21 37 49 56 62 63 85 b = 2 2 1 2 2 2 2 2 2 2 2

4   Pass
x = 1; y_correct = 1; assert(isequal(uniqueNum(x),y_correct))

a = 1 b = 1

5   Pass
[x, y] = test(1000, 1000); assert(isequal(uniqueNum(x),y)) function [input, unique] = test(n,m) unique = randi(n); array = [reshape(repmat(randi(n, 1, m), 2,1),1,[]), unique]; input = array(randperm(2*m+1)); end

a = Columns 1 through 15 1 3 5 7 8 9 10 11 12 13 15 17 20 21 22 Columns 16 through 30 23 24 25 26 27 29 30 31 32 33 34 37 40 46 47 Columns 31 through 45 51 55 57 58 61 62 63 64 66 67 69 70 71 72 74 Columns 46 through 60 75 76 80 81 83 84 85 90 91 92 93 94 96 97 98 Columns 61 through 75 99 100 101 108 109 112 113 114 116 117 119 120 121 122 125 Columns 76 through 90 128 129 130 131 132 133 135 136 137 138 139 140 141 142 144 Columns 91 through 105 145 146 149 151 152 153 154 156 160 162 163 164 169 172 173 Columns 106 through 120 175 176 179 180 181 183 184 186 187 188 189 190 193 197 198 Columns 121 through 135 200 201 202 203 204 206 208 209 211 213 214 219 220 223 228 Columns 136 through 150 231 232 233 235 238 239 241 242 244 245 246 249 252 254 255 Columns 151 through 165 256 257 258 260 264 265 267 269 270 272 273 274 276 277 280 Columns 166 through 180 281 282 283 284 285 286 287 288 290 291 294 295 296 297 298 Columns 181 through 195 299 300 304 307 309 311 314 315 316 318 319 322 323 325 326 Columns 196 through 210 327 328 329 330 332 333 334 336 338 341 342 344 345 346 348 Columns 211 through 225 349 350 351 352 353 354 355 357 360 361 362 363 365 366 367 Columns 226 through 240 368 369 370 371 372 377 379 381 382 383 384 385 386 388 393 Columns 241 through 255 394 396 397 399 401 402 403 405 407 408 409 410 411 412 413 Columns 256 through 270 416 417 418 419 421 422 424 426 427 429 432 433 434 436 437 Columns 271 through 285 438 439 440 442 443 444 445 447 448 450 451 453 458 459 460 Columns 286 through 300 462 463 464 465 466 467 468 469 470 471 472 475 478 479 480 Columns 301 through 315 481 482 483 484 485 487 488 490 492 494 495 496 497 498 501 Columns 316 through 330 502 503 504 505 506 507 511 513 514 517 518 519 521 522 523 Columns 331 through 345 524 525 529 530 531 532 533 534 535 536 538 539 540 542 544 Columns 346 through 360 545 546 547 548 552 553 555 557 559 562 563 564 565 567 568 Columns 361 through 375 569 571 574 575 577 578 579 581 582 583 584 585 586 587 588 Columns 376 through 390 592 594 596 597 598 599 600 601 602 603 604 607 610 612 613 Columns 391 through 405 614 616 619 620 621 622 623 625 626 629 631 634 635 637 641 Columns 406 through 420 642 645 647 648 650 652 655 657 658 659 662 663 664 666 668 Columns 421 through 435 671 673 674 675 676 677 680 681 682 683 685 686 688 689 690 Columns 436 through 450 693 694 695 696 697 698 699 701 702 705 706 707 710 711 712 Columns 451 through 465 713 714 715 718 721 722 726 728 729 732 733 734 735 736 737 Columns 466 through 480 740 742 743 744 747 749 750 752 754 755 758 762 764 766 767 Columns 481 through 495 769 770 771 773 774 775 776 777 778 780 781 784 785 786 788 Columns 496 through 510 789 790 791 792 793 795 798 800 802 803 806 807 808 810 812 Columns 511 through 525 813 814 815 816 817 818 820 825 826 829 830 831 832 834 838 Columns 526 through 540 839 840 841 846 847 848 851 853 855 856 857 860 861 862 863 Columns 541 through 555 864 865 866 867 868 871 873 874 875 876 878 879 880 881 882 Columns 556 through 570 883 884 885 887 888 889 891 894 895 897 898 899 901 902 903 Columns 571 through 585 904 905 906 907 909 911 912 914 917 919 920 921 923 924 925 Columns 586 through 600 926 929 930 932 933 936 939 942 943 944 946 947 949 950 952 Columns 601 through 615 953 954 955 956 958 960 962 963 964 966 968 969 970 976 978 Columns 616 through 630 980 981 982 983 984 985 986 987 988 991 992 993 994 996 997 Columns 631 through 632 998 1000 b = Columns 1 through 30 2 2 2 2 4 4 6 2 4 2 4 2 2 2 2 2 4 2 6 2 4 2 2 2 6 4 4 2 2 6 Columns 31 through 60 2 4 6 2 4 4 4 2 2 6 4 4 2 2 6 4 6 2 4 2 2 2 2 2 2 2 2 4 6 2 Columns 61 through 90 2 2 6 2 4 2 2 2 2 4 2 4 4 2 2 4 2 2 2 6 4 2 4 2 2 8 2 8 2 2 Columns 91 through 120 2 8 4 4 2 2 2 2 6 4 2 6 2 6 4 2 2 4 2 2 2 2 4 2 4 4 4 2 4 6 Columns 121 through 150 4 2 2 6 2 2 4 2 4 4 4 2 4 4 2 6 2 2 2 2 2 4 2 6 2 4 2 4 4 2 Columns 151 through 180 2 2 4 4 4 4 2 8 2 4 2 2 2 2 2 2 2 4...