Cody

Solution 2183326

Submitted on 30 Mar 2020 by Michael
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   Pass
f = counter(0,1); assert(isequal(f(),0)) assert(isequal(f(),1)) assert(isequal(2,f())) assert(isequal(3,f()))

y = 0 val = 1 y = 1 val = 2 y = 2 val = 3 y = 3 val = 4

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

y = 1 val = 1 y = 1 val = 1 y = 1 val = 1 y = 1 val = 1

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

y = 10 val = 12 y = 12 val = 14 y = 14 val = 16 y = 16 val = 18

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

y = 0 val = 5 y = 5 val = 10 y = 10 val = 15 y = 15 val = 20 y = 20 val = 25 y = 25 val = 30 y = 30 val = 35

6   Pass
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 = 10 val = 17 y = 17 val = 24 y = 24 val = 31 y = 31 val = 38 y = 38 val = 45 y = 45 val = 52 y = 52 val = 59 y = 59 val = 66 y = 66 val = 73 y = 73 val = 80 y = 80 val = 87 y = 87 val = 94 y = 94 val = 101 y = 101 val = 108 y = 108 val = 115 y = 115 val = 122 y = 122 val = 129 y = 129 val = 136 y = 136 val = 143 y = 143 val = 150 y = 150 val = 157 y = 157 val = 164 y = 164 val = 171 y = 171 val = 178 y = 178 val = 185 y = 185 val = 192 y = 192 val = 199 y = 199 val = 206 y = 206 val = 213 y = 213 val = 220 y = 220 val = 227 y = 227 val = 234 y = 234 val = 241 y = 241 val = 248 y = 248 val = 255 y = 255 val = 262 y = 262 val = 269 y = 269 val = 276 y = 276 val = 283 y = 283 val = 290 y = 290 val = 297 y = 297 val = 304 y = 304 val = 311 y = 311 val = 318 y = 318 val = 325 y = 325 val = 332 y = 332 val = 339 y = 339 val = 346 y = 346 val = 353 y = 353 val = 360 y = 360 val = 367 y = 367 val = 374 y = 374 val = 381 y = 381 val = 388 y = 388 val = 395 y = 395 val = 402 y = 402 val = 409 y = 409 val = 416 y = 416 val = 423 y = 423 val = 430 y = 430 val = 437 y = 437 val = 444 y = 444 val = 451 y = 451 val = 458 y = 458 val = 465 y = 465 val = 472 y = 472 val = 479 y = 479 val = 486 y = 486 val = 493 y = 493 val = 500 y = 500 val = 507 y = 507 val = 514 y = 514 val = 521 y = 521 val = 528 y = 528 val = 535 y = 535 val = 542 y = 542 val = 549 y = 549 val = 556 y = 556 val = 563 y = 563 val = 570 y = 570 val = 577 y = 577 val = 584 y = 584 val = 591 y = 591 val = 598 y = 598 val = 605 y = 605 val = 612 y = 612 val = 619 y = 619 val = 626 y = 626 val = 633 y = 633 val = 640 y = 640 val = 647 y = 647 val = 654 y = 654 val = 661 y = 661 val = 668 y = 668 val = 675 y = 675 val = 682 y = 682 val = 689 y = 689 val = 696 y = 696 val = 703 y = 703 val = 710 y = 710 val = 717 y = 717 val = 724 y = 724 val = 731 y = 731 val = 738 y = 738 val = 745 y = 745 val = 752 y = 752 val = 759 y = 759 val = 766 y = 766 val = 773 y = 773 val = 780 y = 780 val = 787 y = 787 val = 794 y = 794 val = 801 y = 801 val = 808 y = 808 val = 815 y = 815 val = 822 y = 822 val = 829 y = 829 val = 836 y = 836 val = 843 y = 843 val = 850 y = 850 val = 857 y = 857 val = 864 y = 864 val = 871 y = 871 val = 878 y = 878 val = 885 y = 885 val = 892 y = 892 val = 899 y = 899 val = 906 y = 906 val = 913 y = 913 val = 920 y = 920 val = 927 y = 927 val = 934 y = 934 val = 941 y = 941 val = 948 y = 948 val = 955 y = 955 val = 962 y = 962 val = 969 y = 969 val = 976 y = 976 val = 983 y = 983 val = 990 y = 990 val = 997 y = 997 val = 1004 y = 1004 val = 1011 y = 1011 val = 1018 y = 1018 val = 1025 y = 1025 val = 1032 y = 1032 val = 1039 y = 1039 val = 1046 y = 1046 val = 1053 y = 1053 val = 1060 y = 1060 val = 1067 y = 1067 val = 1074 y = 1074 val = 1081 y = 1081 val = 1088 y = 1088 val = 1095 y = 1095 val = 1102 y = 1102 val = 1109 y = 1109 val = 1116 y = 1116 val = 1123 y = 1123 val = 1130 y = 1130 val = 1137 y = 1137 val = 1144 y = 1144 val = 1151 y = 1151 val = 1158 y = 1158 val = 1165 y = 1165 val = 1172 y = 1172 val = 1179 y = 1179 val = 1186 y = 1186 val = 1193 y = 1193 val = 1200 y = 1200 val = 1207 y = 1207 val = 1214 y = 1214 val = 1221 y = 1221 val = 1228 y = 1228 val = 1235 y = 1235 val = 1242 y = 1242 val = 1249 y = 1249 val = 1256 y = 1256 val = 1263 y = 1263 val = 1270 y = 1270 val = 1277 y = 1277 val = 1284 y = 1284 val = 1291 y = 1291 val = 1298 y = 1298 val = 1305 y = 1305 val = 1312 y = 1312 val = 1319 y = 1319 val = 1326 y = 1326 val = 1333 y = 1333 val = 1340 y = 1340 val = 1347 y = 1347 val = 1354 y = 1354 val = 1361 y = 1361 val = 1368 y = 1368 val = 1375 y = 1375 val = 1382 y = 1382 val = 1389 y = 1389 val = 1396 y = 1396 val = 1403 y = 1403 val = 1410 y = 1410 val = 1417 y = 1417 val = 1424 y = 1424 val = 1431 y = 1431 val = 1438 y = 1438 val = 1445 y = 1445 val = 1452 y = 1452 val = 1459 y = 1459 val = 1466 y = 1466 val = 1473 y = 1473 val = 1480 y = 1480 val = 1487 y = 1487 val = 1494 y = 1494 val = 1501 y = 1501 val = 1508 y = 1508 val = 1515 y = 1515 val = 1522 y = 1522 val = 1529 y = 1529 val = 1536 y = 1536 val = 1543 y = 1543 val = 1550 y = 1550 val = 1557 y = 1557 val = 1564 y = 1564 val = 1571 y = 1571 val = 1578 y = 1578 val = 1585 y = 1585 val = 1592 y = 1592 val = 1599 y = 1599 val = 1606 y = 1606 val = 1613 y = 1613 val = 1620 y = 1620 val = 1627 y = 1627 val = 1634 y = 1634 val = 1641 y = 1641 val = 1648 y = 1648 val = 1655 y = 1655 val = 1662 y = 1662 val = 1669 y = 1669 val = 1676 y = 1676 val = 1683 y = 1683 val = 1690 y = 1690 val = 1697 y = 1697 val = 1704 y = 1704 val = 1711 y = 1711 val = 1718 y = 1718 val = 1725 y = 1725 val = 1732 y = 1732 val = 1739 y = 1739 val = 1746 y = 1746 val = 1753 y = 1753 val = 1760 y = 1760 val = 1767 y = 1767 val = 1774 y = 1774 val = 1781 y = 1781 val = 1788 y = 1788 val = 1795 y = 1795 val = 1802 y = 1802 val = 1809 y = 1809 val = 1816 y = 1816 val = 1823 y = 1823 val = 1830 y = 1830 val = 1837 y = 1837 val = 1844 y = 1844 val = 1851 y = 1851 val = 1858 y = 1858 val = 1865 y = 1865 val = 1872 y = 1872 val = 1879 y = 1879 val = 1886 y = 1886 val = 1893 y = 1893 val = 1900 y = 1900 val = 1907 y = 1907 val = 1914 y = 1914 val = 1921 y = 1921 val = 1928 y = 1928 val = 1935 y = 1935 val = 1942 y = 1942 val = 1949 y = 1949 val = 1956 y = 1956 va...