Cody

# Problem 1092. Decimation

Solution 181355

Submitted on 24 Dec 2012 by Khaled Hamed
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
%% assert(isequal(decimate(10,3),4))

``` a = 3 6 9 a = 2 5 a = 1 4 a = 2 a = 2 ```

2   Pass
%% assert(isequal(decimate(1024,3),676))

``` a = Columns 1 through 8 3 6 9 12 15 18 21 24 Columns 9 through 16 27 30 33 36 39 42 45 48 Columns 17 through 24 51 54 57 60 63 66 69 72 Columns 25 through 32 75 78 81 84 87 90 93 96 Columns 33 through 40 99 102 105 108 111 114 117 120 Columns 41 through 48 123 126 129 132 135 138 141 144 Columns 49 through 56 147 150 153 156 159 162 165 168 Columns 57 through 64 171 174 177 180 183 186 189 192 Columns 65 through 72 195 198 201 204 207 210 213 216 Columns 73 through 80 219 222 225 228 231 234 237 240 Columns 81 through 88 243 246 249 252 255 258 261 264 Columns 89 through 96 267 270 273 276 279 282 285 288 Columns 97 through 104 291 294 297 300 303 306 309 312 Columns 105 through 112 315 318 321 324 327 330 333 336 Columns 113 through 120 339 342 345 348 351 354 357 360 Columns 121 through 128 363 366 369 372 375 378 381 384 Columns 129 through 136 387 390 393 396 399 402 405 408 Columns 137 through 144 411 414 417 420 423 426 429 432 Columns 145 through 152 435 438 441 444 447 450 453 456 Columns 153 through 160 459 462 465 468 471 474 477 480 Columns 161 through 168 483 486 489 492 495 498 501 504 Columns 169 through 176 507 510 513 516 519 522 525 528 Columns 177 through 184 531 534 537 540 543 546 549 552 Columns 185 through 192 555 558 561 564 567 570 573 576 Columns 193 through 200 579 582 585 588 591 594 597 600 Columns 201 through 208 603 606 609 612 615 618 621 624 Columns 209 through 216 627 630 633 636 639 642 645 648 Columns 217 through 224 651 654 657 660 663 666 669 672 Columns 225 through 232 675 678 681 684 687 690 693 696 Columns 233 through 240 699 702 705 708 711 714 717 720 Columns 241 through 248 723 726 729 732 735 738 741 744 Columns 249 through 256 747 750 753 756 759 762 765 768 Columns 257 through 264 771 774 777 780 783 786 789 792 Columns 265 through 272 795 798 801 804 807 810 813 816 Columns 273 through 280 819 822 825 828 831 834 837 840 Columns 281 through 288 843 846 849 852 855 858 861 864 Columns 289 through 296 867 870 873 876 879 882 885 888 Columns 297 through 304 891 894 897 900 903 906 909 912 Columns 305 through 312 915 918 921 924 927 930 933 936 Columns 313 through 320 939 942 945 948 951 954 957 960 Columns 321 through 328 963 966 969 972 975 978 981 984 Columns 329 through 336 987 990 993 996 999 1002 1005 1008 Columns 337 through 341 1011 1014 1017 1020 1023 a = Columns 1 through 16 2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 Columns 17 through 32 50 53 56 59 62 65 68 71 74 77 80 83 86 89 92 95 Columns 33 through 48 98 101 104 107 110 113 116 119 122 125 128 131 134 137 140 143 Columns 49 through 64 146 149 152 155 158 161 164 167 170 173 176 179 182 185 188 191 Columns 65 through 80 194 197 200 203 206 209 212 215 218 221 224 227 230 233 236 239 Columns 81 through 96 242 245 248 251 254 257 260 263 266 269 272 275 278 281 284 287 Columns 97 through 112 290 293 296 299 302 305 308 311 314 317 320 323 326 329 332 335 Columns 113 through 128 338 341 344 347 350 353 356 359 362 365 368 371 374 377 380 383 Columns 129 through 144 386 389 392 395 398 401 404 407 410 413 416 419 422 425 428 431 Columns 145 through 160 434 437 440 443 446 449 452 455 458 461 464 467 470 473 476 479 Columns 161 through 176 482 485 488 491 494 497 500 503 506 509 512 515 518 521 524 527 Columns 177 through 192 530 533 536 539 542 545 548 551 554 557 560 563 566 569 572 575 Columns 193 through 208 578 581 584 587 590 593 596 599 602 605 608 611 614 617 620 623 Columns 209 through 224 626 629 632 635 638 641 644 647 650 653 656 659 662 665 668 671 Columns 225 through 228 674 677 680 683 a = Columns 1 through 16 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 Columns 17 through 32 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 Columns 33 through 48 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 Columns 49 through 64 147 150 153 156 159 162 165 168 171 174 177 180 183 186 189 192 Columns 65 through 80 195 198 201 204 207 210 213 216 219 222 225 228 231 234 237 240 Columns 81 through 96 243 246 249 252 255 258 261 264 267 270 273 276 279 282 285 288 Columns 97 through 112 291 294 297 300 303 306 309 312 315 318 321 324 327 330 333 336 Columns 113 through 128 339 342 345 348 351 354 357 360 363 366 369 372 375 378 381 384 Columns 129 through 144 387 390 393 396 399 402 405 408 411 414 417 420 423 426 429 432 Columns 145 through 151 435 438 441 444 447 450 453 a = Columns 1 through 16 1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 Columns 17 through 32 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 Columns 33 through 48 97 100 103 106 109 112 115 118 121 124 127 130 133 136 139 142 Columns 49 through 64 145 148 151 154 157 160 163 166 169 172 175 178 181 184 187 190 Columns 65 through 80 193 196 199 202 205 208 211 214 217 220 223 226 229 232 235 238 Columns 81 through 96 241 244 247 250 253 256 259 262 265 268 271 274 277 280 283 286 Columns 97 through 102 289 292 295 298 301 304 a = Columns 1 through 16 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 Columns 17 through 32 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 Columns 33 through 48 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 Columns 49 through 64 147 150 153 156 159 162 165 168 171 174 177 180 183 186 189 192 Columns 65 through 67 195 198 201 a = Columns 1 through 16 2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 Columns 17 through 32 50 53 56 59 62 65 68 71 74 77 80 83 86 89 92 95 Columns 33 through 45 98 101 104 107 110 113 116 119 122 125 128 131 134 a = Columns 1 through 16 2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 Columns 17 through 30 50 53 56 59...```

3   Pass
%% assert(isequal(decimate(2012,50),543))

``` a = Columns 1 through 8 50 100 150 200 250 300 350 400 Columns 9 through 16 450 500 550 600 650 700 750 800 Columns 17 through 24 850 900 950 1000 1050 1100 1150 1200 Columns 25 through 32 1250 1300 1350 1400 1450 1500 1550 1600 Columns 33 through 40 1650 1700 1750 1800 1850 1900 1950 2000 a = Columns 1 through 8 38 88 138 188 238 288 338 388 Columns 9 through 16 438 488 538 588 638 688 738 788 Columns 17 through 24 838 888 938 988 1038 1088 1138 1188 Columns 25 through 32 1238 1288 1338 1388 1438 1488 1538 1588 Columns 33 through 39 1638 1688 1738 1788 1838 1888 1938 a = Columns 1 through 8 16 66 116 166 216 266 316 366 Columns 9 through 16 416 466 516 566 616 666 716 766 Columns 17 through 24 816 866 916 966 1016 1066 1116 1166 Columns 25 through 32 1216 1266 1316 1366 1416 1466 1516 1566 Columns 33 through 39 1616 1666 1716 1766 1816 1866 1916 a = Columns 1 through 8 33 83 133 183 233 283 333 383 Columns 9 through 16 433 483 533 583 633 683 733 783 Columns 17 through 24 833 883 933 983 1033 1083 1133 1183 Columns 25 through 32 1233 1283 1333 1383 1433 1483 1533 1583 Columns 33 through 38 1633 1683 1733 1783 1833 1883 a = Columns 1 through 8 39 89 139 189 239 289 339 389 Columns 9 through 16 439 489 539 589 639 689 739 789 Columns 17 through 24 839 889 939 989 1039 1089 1139 1189 Columns 25 through 32 1239 1289 1339 1389 1439 1489 1539 1589 Columns 33 through 37 1639 1689 1739 1789 1839 a = Columns 1 through 8 33 83 133 183 233 283 333 383 Columns 9 through 16 433 483 533 583 633 683 733 783 Columns 17 through 24 833 883 933 983 1033 1083 1133 1183 Columns 25 through 32 1233 1283 1333 1383 1433 1483 1533 1583 Columns 33 through 36 1633 1683 1733 1783 a = Columns 1 through 8 14 64 114 164 214 264 314 364 Columns 9 through 16 414 464 514 564 614 664 714 764 Columns 17 through 24 814 864 914 964 1014 1064 1114 1164 Columns 25 through 32 1214 1264 1314 1364 1414 1464 1514 1564 Columns 33 through 36 1614 1664 1714 1764 a = Columns 1 through 8 31 81 131 181 231 281 331 381 Columns 9 through 16 431 481 531 581 631 681 731 781 Columns 17 through 24 831 881 931 981 1031 1081 1131 1181 Columns 25 through 32 1231 1281 1331 1381 1431 1481 1531 1581 Columns 33 through 35 1631 1681 1731 a = Columns 1 through 8 34 84 134 184 234 284 334 384 Columns 9 through 16 434 484 534 584 634 684 734 784 Columns 17 through 24 834 884 934 984 1034 1084 1134 1184 Columns 25 through 32 1234 1284 1334 1384 1434 1484 1534 1584 Columns 33 through 34 1634 1684 a = Columns 1 through 8 22 72 122 172 222 272 322 372 Columns 9 through 16 422 472 522 572 622 672 722 772 Columns 17 through 24 822 872 922 972 1022 1072 1122 1172 Columns 25 through 32 1222 1272 1322 1372 1422 1472 1522 1572 Columns 33 through 34 1622 1672 a = Columns 1 through 8 44 94 144 194 244 294 344 394 Columns 9 through 16 444 494 544 594 644 694 744 794 Columns 17 through 24 844 894 944 994 1044 1094 1144 1194 Columns 25 through 32 1244 1294 1344 1394 1444 1494 1544 1594 Column 33 1644 a = Columns 1 through 8 50 100 150 200 250 300 350 400 Columns 9 through 16 450 500 550 600 650 700 750 800 Columns 17 through 24 850 900 950 1000 1050 1100 1150 1200 Columns 25 through 32 1250 1300 1350 1400 1450 1500 1550 1600 a = Columns 1 through 8 39 89 139 189 239 289 339 389 Columns 9 through 16 439 489 539 589 639 689 739 789 Columns 17 through 24 839 889 939 989 1039 1089 1139 1189 Columns 25 through 31 1239 1289 1339 1389 1439 1489 1539 a = Columns 1 through 8 10 60 110 160 210 260 310 360 Columns 9 through 16 410 460 510 560 610 660 710 760 Columns 17 through 24 810 860 910 960 1010 1060 1110 1160 Columns 25 through 31 1210 1260 1310 1360 1410 1460 1510 a = Columns 1 through 8 12 62 112 162 212 262 312 362 Columns 9 through 16 412 462 512 562 612 662 712 762 Columns 17 through 24 812 862 912 962 1012 1062 1112 1162 Columns 25 through 31 1212 1262 1312 1362 1412 1462 1512 a = Columns 1 through 8 45 95 145 195 245 295 345 395 Columns 9 through 16 445 495 545 595 645 695 745 795 Columns 17 through 24 845 895 945 995 1045 1095 1145 1195 Columns 25 through 29 1245 1295 1345 1395 1445 a = Columns 1 through 8 9 59 109 159 209 259 309 359 Columns 9 through 16 409 459 509 559 609 659 709 759 Columns 17 through 24 809 859 909 959 1009 1059 1109 1159 Columns 25 through 29 1209 1259 1309 1359 1409 a = Columns 1 through 8 2 52 102 152 202 252 302 352 Columns 9 through 16 402 452 502 552 602 652 702 752 Columns 17 through 24 802 852 902 952 1002 1052 1102 1152 Columns 25 through 29 1202 1252 1302 1352 1402 a = Columns 1 through 8 24 74 124 174 224 274 324 374 Columns 9 through 16 424 474 524 574 624 674 724 774 Columns 17 through 24 824 874 924 974 1024 1074 1124 1174 Columns 25 through 28 1224 1274 1324 1374 a = Columns 1 through 8 25 75 125 175 225 275 325 375 ...```

4   Pass
%% assert(isequal(decimate(30,5),3))

``` a = 5 10 15 20 25 30 a = 5 10 15 20 a = 1 6 11 16 a = 1 6 11 16 a = 5 10 a = 3 8 a = 3 8 a = 5 a = 4 a = 4 a = 2 a = 2 ```

5   Pass
%% assert(isequal(decimate(10,10),8))

``` a = 10 a = 1 a = 2 a = 4 a = 1 a = 5 a = 2 a = 2 a = 1 ```

6   Fail
%% assert(isequal(decimate(2048,2),1))

``` a = Columns 1 through 8 2 4 6 8 10 12 14 16 Columns 9 through 16 18 20 22 24 26 28 30 32 Columns 17 through 24 34 36 38 40 42 44 46 48 Columns 25 through 32 50 52 54 56 58 60 62 64 Columns 33 through 40 66 68 70 72 74 76 78 80 Columns 41 through 48 82 84 86 88 90 92 94 96 Columns 49 through 56 98 100 102 104 106 108 110 112 Columns 57 through 64 114 116 118 120 122 124 126 128 Columns 65 through 72 130 132 134 136 138 140 142 144 Columns 73 through 80 146 148 150 152 154 156 158 160 Columns 81 through 88 162 164 166 168 170 172 174 176 Columns 89 through 96 178 180 182 184 186 188 190 192 Columns 97 through 104 194 196 198 200 202 204 206 208 Columns 105 through 112 210 212 214 216 218 220 222 224 Columns 113 through 120 226 228 230 232 234 236 238 240 Columns 121 through 128 242 244 246 248 250 252 254 256 Columns 129 through 136 258 260 262 264 266 268 270 272 Columns 137 through 144 274 276 278 280 282 284 286 288 Columns 145 through 152 290 292 294 296 298 300 302 304 Columns 153 through 160 306 308 310 312 314 316 318 320 Columns 161 through 168 322 324 326 328 330 332 334 336 Columns 169 through 176 338 340 342 344 346 348 350 352 Columns 177 through 184 354 356 358 360 362 364 366 368 Columns 185 through 192 370 372 374 376 378 380 382 384 Columns 193 through 200 386 388 390 392 394 396 398 400 Columns 201 through 208 402 404 406 408 410 412 414 416 Columns 209 through 216 418 420 422 424 426 428 430 432 Columns 217 through 224 434 436 438 440 442 444 446 448 Columns 225 through 232 450 452 454 456 458 460 462 464 Columns 233 through 240 466 468 470 472 474 476 478 480 Columns 241 through 248 482 484 486 488 490 492 494 496 Columns 249 through 256 498 500 502 504 506 508 510 512 Columns 257 through 264 514 516 518 520 522 524 526 528 Columns 265 through 272 530 532 534 536 538 540 542 544 Columns 273 through 280 546 548 550 552 554 556 558 560 Columns 281 through 288 562 564 566 568 570 572 574 576 Columns 289 through 296 578 580 582 584 586 588 590 592 Columns 297 through 304 594 596 598 600 602 604 606 608 Columns 305 through 312 610 612 614 616 618 620 622 624 Columns 313 through 320 626 628 630 632 634 636 638 640 Columns 321 through 328 642 644 646 648 650 652 654 656 Columns 329 through 336 658 660 662 664 666 668 670 672 Columns 337 through 344 674 676 678 680 682 684 686 688 Columns 345 through 352 690 692 694 696 698 700 702 704 Columns 353 through 360 706 708 710 712 714 716 718 720 Columns 361 through 368 722 724 726 728 730 732 734 736 Columns 369 through 376 738 740 742 744 746 748 750 752 Columns 377 through 384 754 756 758 760 762 764 766 768 Columns 385 through 392 770 772 774 776 778 780 782 784 Columns 393 through 400 786 788 790 792 794 796 798 800 Columns 401 through 408 802 804 806 808 810 812 814 816 Columns 409 through 416 818 820 822 824 826 828 830 832 Columns 417 through 424 834 836 838 840 842 844 846 848 Columns 425 through 432 850 852 854 856 858 860 862 864 Columns 433 through 440 866 868 870 872 874 876 878 880 Columns 441 through 448 882 884 886 888 890 892 894 896 Columns 449 through 456```