Cody

# Problem 44345. MATLAB Counter

Solution 1289707

Submitted on 16 Oct 2017 by Reggie Wilcox
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()))

c = -1 y = function_handle with value: @counter/chandle c = 0 y = 0 c = 1 y = 1 c = 2 y = 2 c = 3 y = 3

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

c = 1 y = function_handle with value: @counter/chandle c = 1 y = 1 c = 1 y = 1 c = 1 y = 1 c = 1 y = 1

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

c = 8 y = function_handle with value: @counter/chandle c = 10 y = 10 c = 12 y = 12 c = 14 y = 14 c = 16 y = 16

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))

c = -5 y = function_handle with value: @counter/chandle c = 0 y = 0 c = 5 y = 5 c = 10 y = 10 c = 15 y = 15 c = 20 y = 20 c = 25 y = 25 c = 30 y = 30

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))

c = -5 y = function_handle with value: @counter/chandle c = 3 y = 3 c = 11 y = 11 c = 19 y = 19 c = 27 y = 27 c = 35 y = 35 c = 43 y = 43 c = 51 y = 51 c = 59 y = 59 c = 67 y = 67 c = 75 y = 75 c = 83 y = 83 c = 91 y = 91 c = 99 y = 99 c = 107 y = 107 c = 115 y = 115 c = 123 y = 123 c = 131 y = 131 c = 139 y = 139 c = 147 y = 147 c = 155 y = 155 c = 163 y = 163 c = 171 y = 171 c = 179 y = 179 c = 187 y = 187 c = 195 y = 195 c = 203 y = 203 c = 211 y = 211 c = 219 y = 219 c = 227 y = 227 c = 235 y = 235 c = 243 y = 243 c = 251 y = 251 c = 259 y = 259 c = 267 y = 267 c = 275 y = 275 c = 283 y = 283 c = 291 y = 291 c = 299 y = 299 c = 307 y = 307 c = 315 y = 315 c = 323 y = 323 c = 331 y = 331 c = 339 y = 339 c = 347 y = 347 c = 355 y = 355 c = 363 y = 363 c = 371 y = 371 c = 379 y = 379 c = 387 y = 387 c = 395 y = 395 c = 403 y = 403 c = 411 y = 411 c = 419 y = 419 c = 427 y = 427 c = 435 y = 435 c = 443 y = 443 c = 451 y = 451 c = 459 y = 459 c = 467 y = 467 c = 475 y = 475 c = 483 y = 483 c = 491 y = 491 c = 499 y = 499 c = 507 y = 507 c = 515 y = 515 c = 523 y = 523 c = 531 y = 531 c = 539 y = 539 c = 547 y = 547 c = 555 y = 555 c = 563 y = 563 c = 571 y = 571 c = 579 y = 579 c = 587 y = 587 c = 595 y = 595 c = 603 y = 603 c = 611 y = 611 c = 619 y = 619 c = 627 y = 627 c = 635 y = 635 c = 643 y = 643 c = 651 y = 651 c = 659 y = 659 c = 667 y = 667 c = 675 y = 675 c = 683 y = 683 c = 691 y = 691 c = 699 y = 699 c = 707 y = 707 c = 715 y = 715 c = 723 y = 723 c = 731 y = 731 c = 739 y = 739 c = 747 y = 747 c = 755 y = 755 c = 763 y = 763 c = 771 y = 771 c = 779 y = 779 c = 787 y = 787 c = 795 y = 795 c = 803 y = 803 c = 811 y = 811 c = 819 y = 819 c = 827 y = 827 c = 835 y = 835 c = 843 y = 843 c = 851 y = 851 c = 859 y = 859 c = 867 y = 867 c = 875 y = 875 c = 883 y = 883 c = 891 y = 891 c = 899 y = 899 c = 907 y = 907 c = 915 y = 915 c = 923 y = 923 c = 931 y = 931 c = 939 y = 939 c = 947 y = 947 c = 955 y = 955 c = 963 y = 963 c = 971 y = 971 c = 979 y = 979 c = 987 y = 987 c = 995 y = 995 c = 1003 y = 1003 c = 1011 y = 1011 c = 1019 y = 1019 c = 1027 y = 1027 c = 1035 y = 1035 c = 1043 y = 1043 c = 1051 y = 1051 c = 1059 y = 1059 c = 1067 y = 1067 c = 1075 y = 1075 c = 1083 y = 1083 c = 1091 y = 1091 c = 1099 y = 1099 c = 1107 y = 1107 c = 1115 y = 1115 c = 1123 y = 1123 c = 1131 y = 1131 c = 1139 y = 1139 c = 1147 y = 1147 c = 1155 y = 1155 c = 1163 y = 1163 c = 1171 y = 1171 c = 1179 y = 1179 c = 1187 y = 1187 c = 1195 y = 1195 c = 1203 y = 1203 c = 1211 y = 1211 c = 1219 y = 1219 c = 1227 y = 1227 c = 1235 y = 1235 c = 1243 y = 1243 c = 1251 y = 1251 c = 1259 y = 1259 c = 1267 y = 1267 c = 1275 y = 1275 c = 1283 y = 1283 c = 1291 y = 1291 c = 1299 y = 1299 c = 1307 y = 1307 c = 1315 y = 1315 c = 1323 y = 1323 c = 1331 y = 1331 c = 1339 y = 1339 c = 1347 y = 1347 c = 1355 y = 1355 c = 1363 y = 1363 c = 1371 y = 1371 c = 1379 y = 1379 c = 1387 y = 1387 c = 1395 y = 1395 c = 1403 y = 1403 c = 1411 y = 1411 c = 1419 y = 1419 c = 1427 y = 1427 c = 1435 y = 1435 c = 1443 y = 1443 c = 1451 y = 1451 c = 1459 y = 1459 c = 1467 y = 1467 c = 1475 y = 1475 c = 1483 y = 1483 c = 1491 y = 1491 c = 1499 y = 1499 c = 1507 y = 1507 c = 1515 y = 1515 c = 1523 y = 1523 c = 1531 y = 1531 c = 1539 y = 1539 c = 1547 y = 1547 c = 1555 y = 1555 c = 1563 y = 1563 c = 1571 y = 1571 c = 1579 y = 1579 c = 1587 y = 1587 c = 1595 y = 1595 c = 1603 y = 1603 c = 1611 y = 1611 c = 1619 y = 1619 c = 1627 y = 1627 c = 1635 y = 1635 c = 1643 y = 1643 c = 1651 y = 1651 c = 1659 y = 1659 c = 1667 y = 1667 c = 1675 y = 1675 c = 1683 y = 1683 c = 1691 y = 1691 c = 1699 y = 1699 c = 1707 y = 1707 c = 1715 y = 1715 c = 1723 y = 1723 c = 1731 y = 1731 c = 1739 y = 1739 c = 1747 y = 1747 c = 1755 y = 1755 c = 1763 y = 1763 c = 1771 y = 1771 c = 1779 y = 1779 c = 1787 y = 1787 c = 1795 y = 1795 c = 1803 y = 1803 c = 1811 y = 1811 c = 1819 y = 1819 c = 1827 y = 1827 c = 1835 y = 1835 c = 1843 y = 1843 c = 1851 y = 1851 c = 1859 y = 1859 c = 1867 y = 1867 c = 1875 y = 1875 c = 1883 y = 1883 c = 1891 y = 1891 c = 1899 y = 1899 c = 1907 y = 1907 c = 1915 y = 1915 c = 1923 y = 1923 c = 1931 y = 1931 c = 1939 y = 1939 c = 1947 y = 1947 c = 1955 y = 1955 c = 1963 y = 1963 c = 1971 y = 1971 c = 1979 y = 1979 c = 1987 y = 1987 c = 1995 y = 1995 c = 2003 y = 2003 c = 2011 y = 2011 c = 2019 y = 2019 c = 2027 y = 2027 c = 2035 y = 2035 c = 2043 y = 2043 c = 2051 y = 2051 c = 2059 y = 2059 c = 2067 y = 2067 c = 2075 y = 2075 c = 2083 y = 2083 c = 2091 y = 2091 c = 2099 y = 2099 c = 2107 y = 2107 c = 2115 y = 2115 c = 2123 y = 2123 c = 2131 y = 2131 c = 2139 y = 2139 c = 2147 y = 2147 c = 2155 y = 2155 c = 2163 y = 2163 c = 2171 y = 2171 c = 2179 y = 2179 c = 2187 y = 2187 c = 2195 y = 2195 c = 2203 y = 2203 c = 2211 y = 2211 c = 2219 y = 2219 c = 2227 y = 2227 c = 2235 y = 2235 c = 2243 y = 2243 c = 2251 y = 2251 c = 2259 y = 2259 c = 2267 y = 2267 c = 2275 y = 2275 c = 2283 y = ...