Cody

# Problem 2481. Mongean Shuffle : 2

Solution 2087549

Submitted on 10 Jan 2020 by Rebecca Gasper
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 = 52; y_correct = 12; assert(isequal(Mnum(x),y_correct))

outdeck = Columns 1 through 30 52 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 1 3 5 7 Columns 31 through 52 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 outdeck = Columns 1 through 30 51 47 43 39 35 31 27 23 19 15 11 7 3 2 6 10 14 18 22 26 30 34 38 42 46 50 52 48 44 40 Columns 31 through 52 36 32 28 24 20 16 12 8 4 1 5 9 13 17 21 25 29 33 37 41 45 49 outdeck = Columns 1 through 30 49 41 33 25 17 9 1 8 16 24 32 40 48 50 42 34 26 18 10 2 7 15 23 31 39 47 51 43 35 27 Columns 31 through 52 19 11 3 6 14 22 30 38 46 52 44 36 28 20 12 4 5 13 21 29 37 45 outdeck = Columns 1 through 30 45 29 13 4 20 36 52 38 22 6 11 27 43 47 31 15 2 18 34 50 40 24 8 9 25 41 49 33 17 1 Columns 31 through 52 16 32 48 42 26 10 7 23 39 51 35 19 3 14 30 46 44 28 12 5 21 37 outdeck = Columns 1 through 30 37 5 28 46 14 19 51 23 10 42 32 1 33 41 9 24 50 18 15 47 27 6 38 36 4 29 45 13 20 52 Columns 31 through 52 22 11 43 31 2 34 40 8 25 49 17 16 48 26 7 39 35 3 30 44 12 21 outdeck = Columns 1 through 30 21 44 3 39 26 16 49 8 34 31 11 52 13 29 36 6 47 18 24 41 1 42 23 19 46 5 37 28 14 51 Columns 31 through 52 10 32 33 9 50 15 27 38 4 45 20 22 43 2 40 25 17 48 7 35 30 12 outdeck = Columns 1 through 30 12 35 48 25 2 22 45 38 15 9 32 51 28 5 19 42 41 18 6 29 52 31 8 16 39 44 21 3 26 49 Columns 31 through 52 34 11 13 36 47 24 1 23 46 37 14 10 33 50 27 4 20 43 40 17 7 30 outdeck = Columns 1 through 30 30 17 43 4 50 10 37 23 24 36 11 49 3 44 16 31 29 18 42 5 51 9 38 22 25 35 12 48 2 45 Columns 31 through 52 15 32 28 19 41 6 52 8 39 21 26 34 13 47 1 46 14 33 27 20 40 7 outdeck = Columns 1 through 30 7 20 33 46 47 34 21 8 6 19 32 45 48 35 22 9 5 18 31 44 49 36 23 10 4 17 30 43 50 37 Columns 31 through 52 24 11 3 16 29 42 51 38 25 12 2 15 28 41 52 39 26 13 1 14 27 40 outdeck = Columns 1 through 30 40 14 13 39 41 15 12 38 42 16 11 37 43 17 10 36 44 18 9 35 45 19 8 34 46 20 7 33 47 21 Columns 31 through 52 6 32 48 22 5 31 49 23 4 30 50 24 3 29 51 25 2 28 52 26 1 27 outdeck = Columns 1 through 30 27 26 28 25 29 24 30 23 31 22 32 21 33 20 34 19 35 18 36 17 37 16 38 15 39 14 40 13 41 12 Columns 31 through 52 42 11 43 10 44 9 45 8 46 7 47 6 48 5 49 4 50 3 51 2 52 1 outdeck = Columns 1 through 30 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 Columns 31 through 52 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

2   Pass
x = 10; y_correct = 6; assert(isequal(Mnum(x),y_correct))

outdeck = 10 8 6 4 2 1 3 5 7 9 outdeck = 9 5 1 4 8 10 6 2 3 7 outdeck = 7 2 10 4 5 9 1 8 6 3 outdeck = 3 8 9 4 2 7 10 5 1 6 outdeck = 6 5 7 4 8 3 9 2 10 1 outdeck = 1 2 3 4 5 6 7 8 9 10

3   Pass
x = 9; y_correct = 4; assert(isequal(Mnum(x),y_correct))

outdeck = 8 6 4 2 1 3 5 7 9 outdeck = 7 3 2 6 8 4 1 5 9 outdeck = 5 4 6 3 7 2 8 1 9 outdeck = 1 2 3 4 5 6 7 8 9

4   Pass
x = 1000; y_correct = 308; assert(isequal(Mnum(x),y_correct))

outdeck = Columns 1 through 15 1000 998 996 994 992 990 988 986 984 982 980 978 976 974 972 Columns 16 through 30 970 968 966 964 962 960 958 956 954 952 950 948 946 944 942 Columns 31 through 45 940 938 936 934 932 930 928 926 924 922 920 918 916 914 912 Columns 46 through 60 910 908 906 904 902 900 898 896 894 892 890 888 886 884 882 Columns 61 through 75 880 878 876 874 872 870 868 866 864 862 860 858 856 854 852 Columns 76 through 90 850 848 846 844 842 840 838 836 834 832 830 828 826 824 822 Columns 91 through 105 820 818 816 814 812 810 808 806 804 802 800 798 796 794 792 Columns 106 through 120 790 788 786 784 782 780 778 776 774 772 770 768 766 764 762 Columns 121 through 135 760 758 756 754 752 750 748 746 744 742 740 738 736 734 732 Columns 136 through 150 730 728 726 724 722 720 718 716 714 712 710 708 706 704 702 Columns 151 through 165 700 698 696 694 692 690 688 686 684 682 680 678 676 674 672 Columns 166 through 180 670 668 666 664 662 660 658 656 654 652 650 648 646 644 642 Columns 181 through 195 640 638 636 634 632 630 628 626 624 622 620 618 616 614 612 Columns 196 through 210 610 608 606 604 602 600 598 596 594 592 590 588 586 584 582 Columns 211 through 225 580 578 576 574 572 570 568 566 564 562 560 558 556 554 552 Columns 226 through 240 550 548 546 544 542 540 538 536 534 532 530 528 526 524 522 Columns 241 through 255 520 518 516 514 512 510 508 506 504 502 500 498 496 494 492 Columns 256 through 270 490 488 486 484 482 480 478 476 474 472 470 468 466 464 462 Columns 271 through 285 460 458 456 454 452 450 448 446 444 442 440 438 436 434 432 Columns 286 through 300 430 428 426 424 422 420 418 416 414 412 410 408 406 404 402 Columns 301 through 315 400 398 396 394 392 390 388 386 384 382 380 378 376 374 372 Columns 316 through 330 370 368 366 364 362 360 358 356 354 352 350 348 346 344 342 Columns 331 through 345 340 338 336 334 332 330 328 326 324 322 320 318 316 314 312 Columns 346 through 360 310 308 306 304 302 300 298 296 294 292 290 288 286 284 282 Columns 361 through 375 280 278 276 274 272 270 268 266 264 262 260 258 256 254 252 Columns 376 through 390 250 248 246 244 242 240 238 236 234 232 230 228 226 224 222 Columns 391 through 405 220 218 216 214 212 210 208 206 204 202 200 198 196 194 192 Columns 406 through 420 190 188 186 184 182 180 178 176 174 172 170 168 166 164 162 Columns 421 through 435 160 158 156 154 152 150 148 146 144 142 140 138 136 134 132 Columns 436 through 450 130 128 126 124 122 120 118 116 114 112 110 108 106 104 102 Columns 451 through 465 100 98 96 94 92 90 88 86 84 82 80 78 76 74 72 Columns 466 through 480 70 68 66 64 62 60 58 56 54 52 50 48 46 44 42 Columns 481 through 495 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 Columns 496 through 510 10 8 6 4 2 1 3 5 7 9 11 13 15 17 19 Columns 511 through 525 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 Columns 526 through 540 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 Columns 541 through 555 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 Columns 556 through 570 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 Columns 571 through 585 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 Columns 586 through 600 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 Columns 601 through 615 201 203 205 207 209 211 213 215 217 219 221 223 225 227 229 Columns 616 through 630 231 233 235 237 239 241 243 245 247 249 251 253 255 257 259 Columns 631 through 645 261 263 265 267 269 271 273 275 277 279 281 283 285 287 289 Columns 646 through 660 291 293 295 297 299 301 303 305 307 309 311 313 315 317 319 Columns 661 through 675 321 323 325 327 329 331 333 335 337 339 341 343 345 347 349 Columns 676 through 690 351 353 355 357 359 361 363 365 367 369 371 373 375 377 379 Columns 691 through 705 381 383 385 387 389 391 393 395 397 399 401 403 405 407 409 Columns 706 through 720 411 413 415 417 419 421 423 425 427 429 431 433 ...

5   Pass
x = 100; y_correct = 33; assert(isequal(Mnum(x),y_correct))

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

6   Pass
x = 2; y_correct = 2; assert(isequal(Mnum(x),y_correct))

outdeck = 2 1 outdeck = 1 2

7   Pass
x = 17; y_correct = 5; assert(isequal(Mnum(x),y_correct))

outdeck = 16 14 12 10 8 6 4 2 1 3 5 7 9 11 13 15 17 outdeck = 15 11 7 3 2 6 10 14 16 12 8 4 1 5 9 13 17 outdeck = 13 5 4 12 14 6 3 11 15 7 2 10 16 8 1 9 17 outdeck = 9 8 10 7 11 6 12 5 13 4 14 3 15 2 16 1 17 outdeck = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17