Cody

Solution 1345695

Submitted on 15 Nov 2017 by David Verrelli
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 = -3 y = function_handle with value: @counter/chandle c = 7 y = 7 c = 17 y = 17 c = 27 y = 27 c = 37 y = 37 c = 47 y = 47 c = 57 y = 57 c = 67 y = 67 c = 77 y = 77 c = 87 y = 87 c = 97 y = 97 c = 107 y = 107 c = 117 y = 117 c = 127 y = 127 c = 137 y = 137 c = 147 y = 147 c = 157 y = 157 c = 167 y = 167 c = 177 y = 177 c = 187 y = 187 c = 197 y = 197 c = 207 y = 207 c = 217 y = 217 c = 227 y = 227 c = 237 y = 237 c = 247 y = 247 c = 257 y = 257 c = 267 y = 267 c = 277 y = 277 c = 287 y = 287 c = 297 y = 297 c = 307 y = 307 c = 317 y = 317 c = 327 y = 327 c = 337 y = 337 c = 347 y = 347 c = 357 y = 357 c = 367 y = 367 c = 377 y = 377 c = 387 y = 387 c = 397 y = 397 c = 407 y = 407 c = 417 y = 417 c = 427 y = 427 c = 437 y = 437 c = 447 y = 447 c = 457 y = 457 c = 467 y = 467 c = 477 y = 477 c = 487 y = 487 c = 497 y = 497 c = 507 y = 507 c = 517 y = 517 c = 527 y = 527 c = 537 y = 537 c = 547 y = 547 c = 557 y = 557 c = 567 y = 567 c = 577 y = 577 c = 587 y = 587 c = 597 y = 597 c = 607 y = 607 c = 617 y = 617 c = 627 y = 627 c = 637 y = 637 c = 647 y = 647 c = 657 y = 657 c = 667 y = 667 c = 677 y = 677 c = 687 y = 687 c = 697 y = 697 c = 707 y = 707 c = 717 y = 717 c = 727 y = 727 c = 737 y = 737 c = 747 y = 747 c = 757 y = 757 c = 767 y = 767 c = 777 y = 777 c = 787 y = 787 c = 797 y = 797 c = 807 y = 807 c = 817 y = 817 c = 827 y = 827 c = 837 y = 837 c = 847 y = 847 c = 857 y = 857 c = 867 y = 867 c = 877 y = 877 c = 887 y = 887 c = 897 y = 897 c = 907 y = 907 c = 917 y = 917 c = 927 y = 927 c = 937 y = 937 c = 947 y = 947 c = 957 y = 957 c = 967 y = 967 c = 977 y = 977 c = 987 y = 987 c = 997 y = 997 c = 1007 y = 1007 c = 1017 y = 1017 c = 1027 y = 1027 c = 1037 y = 1037 c = 1047 y = 1047 c = 1057 y = 1057 c = 1067 y = 1067 c = 1077 y = 1077 c = 1087 y = 1087 c = 1097 y = 1097 c = 1107 y = 1107 c = 1117 y = 1117 c = 1127 y = 1127 c = 1137 y = 1137 c = 1147 y = 1147 c = 1157 y = 1157 c = 1167 y = 1167 c = 1177 y = 1177 c = 1187 y = 1187 c = 1197 y = 1197 c = 1207 y = 1207 c = 1217 y = 1217 c = 1227 y = 1227 c = 1237 y = 1237 c = 1247 y = 1247 c = 1257 y = 1257 c = 1267 y = 1267 c = 1277 y = 1277 c = 1287 y = 1287 c = 1297 y = 1297 c = 1307 y = 1307 c = 1317 y = 1317 c = 1327 y = 1327 c = 1337 y = 1337 c = 1347 y = 1347 c = 1357 y = 1357 c = 1367 y = 1367 c = 1377 y = 1377 c = 1387 y = 1387 c = 1397 y = 1397 c = 1407 y = 1407 c = 1417 y = 1417 c = 1427 y = 1427 c = 1437 y = 1437 c = 1447 y = 1447 c = 1457 y = 1457 c = 1467 y = 1467 c = 1477 y = 1477 c = 1487 y = 1487 c = 1497 y = 1497 c = 1507 y = 1507 c = 1517 y = 1517 c = 1527 y = 1527 c = 1537 y = 1537 c = 1547 y = 1547 c = 1557 y = 1557 c = 1567 y = 1567 c = 1577 y = 1577 c = 1587 y = 1587 c = 1597 y = 1597 c = 1607 y = 1607 c = 1617 y = 1617 c = 1627 y = 1627 c = 1637 y = 1637 c = 1647 y = 1647 c = 1657 y = 1657 c = 1667 y = 1667 c = 1677 y = 1677 c = 1687 y = 1687 c = 1697 y = 1697 c = 1707 y = 1707 c = 1717 y = 1717 c = 1727 y = 1727 c = 1737 y = 1737 c = 1747 y = 1747 c = 1757 y = 1757 c = 1767 y = 1767 c = 1777 y = 1777 c = 1787 y = 1787 c = 1797 y = 1797 c = 1807 y = 1807 c = 1817 y = 1817 c = 1827 y = 1827 c = 1837 y = 1837 c = 1847 y = 1847 c = 1857 y = 1857 c = 1867 y = 1867 c = 1877 y = 1877 c = 1887 y = 1887 c = 1897 y = 1897 c = 1907 y = 1907 c = 1917 y = 1917 c = 1927 y = 1927 c = 1937 y = 1937 c = 1947 y = 1947 c = 1957 y = 1957 c = 1967 y = 1967 c = 1977 y = 1977 c = 1987 y = 1987 c = 1997 y = 1997 c = 2007 y = 2007 c = 2017 y = 2017 c = 2027 y = 2027 c = 2037 y = 2037 c = 2047 y = 2047 c = 2057 y = 2057 c = 2067 y = 2067 c = 2077 y = 2077 c = 2087 y = 2087 c = 2097 y = 2097 c = 2107 y = 2107 c = 2117 y = 2117 c = 2127 y = 2127 c = 2137 y = 2137 c = 2147 y = 2147 c = 2157 y = 2157 c = 2167 y = 2167 c = 2177 y = 2177 c = 2187 y = 2187 c = 2197 y = 2197 c = 2207 y = 2207 c = 2217 y = 2217 c = 2227 y = 2227 c = 2237 y = 2237 c = 2247 y = 2247 c = 2257 y = 2257 c = 2267 y = 2267 c = 2277 y = 2277 c = 2287 y = 2287 c = 2297 y = 2297 c = 2307 y = 2307 c = 2317 y = 2317 c = 2327 y = 2327 c = 2337 y = 2337 c = 2347 y = 2347 c = 2357 y = 2357 c = 2367 y = 2367 c = 2377 y = 2377 c = 2387 y = 2387 c = 2397 y = 2397 c = 2407 y = 2407 c = 2417 y = 2417 c = 2427 y = 2427 c = 2437 y = 2437 c = 2447 y = 2447 c = 2457 y = 2457 c = 2467 y = 2467 c = 2477 y = 2477 c = 2487 y = 2487 c = 2497 y = 2497 c = 2507 y = 2507 c = 2517 y = 2517 c = 2527 y = 2527 c = 2537 y = 2537 c = 2547 y = 2547 c = 2557 y = 2557 c = 2567 y = 2567 c = 2577 y = 2577 c = 2587 y = 2587 c = 2597 y = 2597 c = 2607 y = 2607 c = 2617 y = 2617 c = 2627 y = 2627 c = 2637 y = 2637 c = 2647 y = 2647 c = 2657 y = 2657 c = 2667 y = 2667 c = 2677 y = 2677 c = 2687 y = 2687 c = 2697 y = 2697 c = 2707 y = 2707 c = 2717 y = 2717 c = 2727 y = 2727 c = 2737 y = 2737 c = 2747 y = 2747 c = 2757 y = 2757 c = 2767 y = 2767 c = 2777 y = 2777 c = ...