Cody

Solution 2105017

Submitted on 24 Jan 2020
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
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','counter.m')

2   Fail
f = counter(0,1); assert(isequal(f(),0)) assert(isequal(f(),1)) assert(isequal(2,f())) assert(isequal(3,f()))

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

Assertion failed.

3   Fail
f = counter(1,0); assert(isequal(f(),1)) assert(isequal(f(),1)) assert(isequal(1,f())) assert(isequal(1,f()))

y = 1×0 empty double row vector

Assertion failed.

4   Fail
f = counter(10,2); assert(isequal(f(),10)) assert(isequal(f(),12)) assert(isequal(14,f())) assert(isequal(16,f()))

y = Columns 1 through 14 10 12 14 16 18 20 22 24 26 28 30 32 34 36 Columns 15 through 28 38 40 42 44 46 48 50 52 54 56 58 60 62 64 Columns 29 through 42 66 68 70 72 74 76 78 80 82 84 86 88 90 92 Columns 43 through 56 94 96 98 100 102 104 106 108 110 112 114 116 118 120 Columns 57 through 70 122 124 126 128 130 132 134 136 138 140 142 144 146 148 Columns 71 through 84 150 152 154 156 158 160 162 164 166 168 170 172 174 176 Columns 85 through 98 178 180 182 184 186 188 190 192 194 196 198 200 202 204 Columns 99 through 112 206 208 210 212 214 216 218 220 222 224 226 228 230 232 Columns 113 through 126 234 236 238 240 242 244 246 248 250 252 254 256 258 260 Columns 127 through 140 262 264 266 268 270 272 274 276 278 280 282 284 286 288 Columns 141 through 154 290 292 294 296 298 300 302 304 306 308 310 312 314 316 Columns 155 through 168 318 320 322 324 326 328 330 332 334 336 338 340 342 344 Columns 169 through 182 346 348 350 352 354 356 358 360 362 364 366 368 370 372 Columns 183 through 196 374 376 378 380 382 384 386 388 390 392 394 396 398 400 Columns 197 through 210 402 404 406 408 410 412 414 416 418 420 422 424 426 428 Columns 211 through 224 430 432 434 436 438 440 442 444 446 448 450 452 454 456 Columns 225 through 238 458 460 462 464 466 468 470 472 474 476 478 480 482 484 Columns 239 through 252 486 488 490 492 494 496 498 500 502 504 506 508 510 512 Columns 253 through 266 514 516 518 520 522 524 526 528 530 532 534 536 538 540 Columns 267 through 280 542 544 546 548 550 552 554 556 558 560 562 564 566 568 Columns 281 through 294 570 572 574 576 578 580 582 584 586 588 590 592 594 596 Columns 295 through 308 598 600 602 604 606 608 610 612 614 616 618 620 622 624 Columns 309 through 322 626 628 630 632 634 636 638 640 642 644 646 648 650 652 Columns 323 through 336 654 656 658 660 662 664 666 668 670 672 674 676 678 680 Columns 337 through 350 682 684 686 688 690 692 694 696 698 700 702 704 706 708 Columns 351 through 364 710 712 714 716 718 720 722 724 726 728 730 732 734 736 Columns 365 through 378 738 740 742 744 746 748 750 752 754 756 758 760 762 764 Columns 379 through 392 766 768 770 772 774 776 778 780 782 784 786 788 790 792 Columns 393 through 406 794 796 798 800 802 804 806 808 810 812 814 816 818 820 Columns 407 through 420 822 824 826 828 830 832 834 836 838 840 842 844 846 848 Columns 421 through 434 850 852 854 856 858 860 862 864 866 868 870 872 874 876 Columns 435 through 448 878 880 882 884 886 888 890 892 894 896 898 900 902 904 Columns 449 through 462 906 908 910 912 914 916 918 920 922 924 926 928 930 932 Columns 463 through 476 934 936 938 940 942 944 946 948 950 952 954 956 958 960 Columns 477 through 490 962 964 966 968 970 972 974 976 978 980 982 984 986 988 Columns 491 through 504 990 992 994 996 998 1000 1002 1004 1006 1008 1010 1012 1014 1016 Columns 505 through 518 1018 1020 1022 1024 1026 1028 1030 1032 1034 1036 1038 1040 1042 1044 Columns 519 through 532 1046 1048 1050 1052 1054 1056 1058 1060 1062 1064 1066 1068 1070 1072 Columns 533 through 546 1074 1076 1078 1080 1082 1084 1086 1088 1090 1092 1094 1096 1098 1100 Columns 547 through 560 1102 1104 1106 1108 1110 1112 1114 1116 1118 1120 1122 1124 1126 1128 Columns 561 through 574 1130 1132 1134 1136 1138 1140 1142 1144 1146 1148 1150 1152 1154 1156 Columns 575 through 588 1158 1160 1162 1164 1166 1168 1170 1172 1174 1176 1178 1180 1182 1184 Columns 589 through 602 1186 1188 1190 1192 1194 1196 1198 1200 1202 1204 1206 1208 1210 1212 Columns 603 through 616 1214 1216 1218 1220 1222 1224 1226 1228 1230 1232 1234 1236 1238 1240 Columns 617 through 630 1242 1244 1246 1248 1250 1252 1254 1256 1258 1260 1262 1264 1266 1268 Columns 631 through 644 1270 1272 1274 1276 1278 1280 1282 1284 1286 1288 1290 1292 1294 1296 Columns 645 through 658 1298 1300 1302 1304 1306 1308 1310 1312 1314 1316 1318 1320 1322 1324 Columns 659 through 672 1326 1328 1330 1332 1334 1336 1338 1340 1342 1344 1346 1348 1350 1352 Columns 673 through 686 1354 1356 1358 1360 1362 1364 1366 1368 1370 1372 1374 1376 1378 1380 Columns 687 through 700 1382 1384 1386 1388 1390 1392 1394 1396 1398 1400 1402 1404 1406 1408 Columns 701 through 714 1410 1412 1414 1416 1418 1420 1422 1424 1426 1428 1430 ...

Assertion failed.

5   Fail
f = counter(0,5); y_correct = [0, 5, 10, 15, 20, 55]; assert(isequal([f() f() f() f() f() f()+f()],y_correct))

y = Columns 1 through 14 0 5 10 15 20 25 30 35 40 45 50 55 60 65 Columns 15 through 28 70 75 80 85 90 95 100 105 110 115 120 125 130 135 Columns 29 through 42 140 145 150 155 160 165 170 175 180 185 190 195 200 205 Columns 43 through 56 210 215 220 225 230 235 240 245 250 255 260 265 270 275 Columns 57 through 70 280 285 290 295 300 305 310 315 320 325 330 335 340 345 Columns 71 through 84 350 355 360 365 370 375 380 385 390 395 400 405 410 415 Columns 85 through 98 420 425 430 435 440 445 450 455 460 465 470 475 480 485 Columns 99 through 112 490 495 500 505 510 515 520 525 530 535 540 545 550 555 Columns 113 through 126 560 565 570 575 580 585 590 595 600 605 610 615 620 625 Columns 127 through 140 630 635 640 645 650 655 660 665 670 675 680 685 690 695 Columns 141 through 154 700 705 710 715 720 725 730 735 740 745 750 755 760 765 Columns 155 through 168 770 775 780 785 790 795 800 805 810 815 820 825 830 835 Columns 169 through 182 840 845 850 855 860 865 870 875 880 885 890 895 900 905 Columns 183 through 196 910 915 920 925 930 935 940 945 950 955 960 965 970 975 Columns 197 through 210 980 985 990 995 1000 1005 1010 1015 1020 1025 1030 1035 1040 1045 Columns 211 through 224 1050 1055 1060 1065 1070 1075 1080 1085 1090 1095 1100 1105 1110 1115 Columns 225 through 238 1120 1125 1130 1135 1140 1145 1150 1155 1160 1165 1170 1175 1180 1185 Columns 239 through 252 1190 1195 1200 1205 1210 1215 1220 1225 1230 1235 1240 1245 1250 1255 Columns 253 through 266 1260 1265 1270 1275 1280 1285 1290 1295 1300 1305 1310 1315 1320 1325 Columns 267 through 280 1330 1335 1340 1345 1350 1355 1360 1365 1370 1375 1380 1385 1390 1395 Columns 281 through 294 1400 1405 1410 1415 1420 1425 1430 1435 1440 1445 1450 1455 1460 1465 Columns 295 through 308 1470 1475 1480 1485 1490 1495 1500 1505 1510 1515 1520 1525 1530 1535 Columns 309 through 322 1540 1545 1550 1555 1560 1565 1570 1575 1580 1585 1590 1595 1600 1605 Columns 323 through 336 1610 1615 1620 1625 1630 1635 1640 1645 1650 1655 1660 1665 1670 1675 Columns 337 through 350 1680 1685 1690 1695 1700 1705 1710 1715 1720 1725 1730 1735 1740 1745 Columns 351 through 364 1750 1755 1760 1765 1770 1775 1780 1785 1790 1795 1800 1805 1810 1815 Columns 365 through 378 1820 1825 1830 1835 1840 1845 1850 1855 1860 1865 1870 1875 1880 1885 Columns 379 through 392 1890 1895 1900 1905 1910 1915 1920 1925 1930 1935 1940 1945 1950 1955 Columns 393 through 406 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015 2020 2025 Columns 407 through 420 2030 2035 2040 2045 2050 2055 2060 2065 2070 2075 2080 2085 2090 2095 Columns 421 through 434 2100 2105 2110 2115 2120 2125 2130 2135 2140 2145 2150 2155 2160 2165 Columns 435 through 448 2170 2175 2180 2185 2190 2195 2200 2205 2210 2215 2220 2225 2230 2235 Columns 449 through 462 2240 2245 2250 2255 2260 2265 2270 2275 2280 2285 2290 2295 2300 2305 Columns 463 through 476 2310 2315 2320 2325 2330 2335 2340 2345 2350 2355 2360 2365 2370 2375 Columns 477 through 490 2380 2385 2390 2395 2400 2405 2410 2415 2420 2425 2430 2435 2440 2445 Columns 491 through 504 2450 2455 2460 2465 2470 2475 2480 2485 2490 2495 2500 2505 2510 2515 Columns 505 through 518 2520 2525 2530 2535 2540 2545 2550 2555 2560 2565 2570 2575 2580 2585 Columns 519 through 532 2590 2595 2600 2605 2610 2615 2620 2625 2630 2635 2640 2645 2650 2655 Columns 533 through 546 2660 2665 2670 2675 2680 2685 2690 2695 2700 2705 2710 2715 2720 2725 Columns 547 through 560 2730 2735 2740 2745 2750 2755 2760 2765 2770 2775 2780 2785 2790 2795 Columns 561 through 574 2800 2805 2810 2815 2820 2825 2830 2835 2840 2845 2850 2855 2860 2865 Columns 575 through 588 2870 2875 2880 2885 2890 2895 2900 2905 2910 2915 2920 2925 2930 2935 Columns 589 through 602 2940 2945 2950 2955 2960 2965 2970 2975 2980 2985 2990 2995 3000 3005 Columns 603 through 616 3010 3015 3020 3025 3030 3035 3040 3045 3050 3055 3060 3065 3070 3075 Columns 617 through 630 3080 3085 3090 3095 3100 3105 3110 3115 3120 3125 3130 3135 3140 3145 Columns 631 through 644 3150 3155 3160 3165 3170 3175 3180 3185 3190 3195 3200 3205 3210 3215 Columns 645 through 658 3220 3225 3230 3235 3240 3245 3250 3255 3260 3265 3270 3275 3280 3285 Columns 659 through 672 3290 3295 3300 3305 3310 3315 3320 3325 3330 3335 3340 3345 3350 3355 Columns 673 through 686 3360 3365 3370 3375 3380 3385 3390 3395 3400 3405 3410 3415 3420 3425 Columns 687 through 700 3430 3435 3440 3445 3450 3455 3460 3465 3470 3475 3480 3485 3490 3495 Columns 701 through 714 3500 3505 3510 3515 3520 3525 3530 3535 3540 3545 3550 ...

Assertion failed.

6   Fail
x0 = randi(10); b = randi(10); f = counter(x0,b); y_correct = x0 + (0:1000)*b; assert(isequal(arrayfun(@(n)f(),0:1000),y_correct))

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

Error using arrayfun Non-scalar in Uniform output, at index 1, output 1. Set 'UniformOutput' to false. Error in Test6 (line 5) assert(isequal(arrayfun(@(n)f(),0:1000),y_correct))