Cody

Solution 1323068

Submitted on 1 Nov 2017 by Jens Kjærgaard Boldsen
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()))

v = 0 v = 1 v = 2 v = 3

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

v = 1 v = 1 v = 1 v = 1

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

v = 10 v = 12 v = 14 v = 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))

v = 0 v = 5 v = 10 v = 15 v = 20 v = 25 v = 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))

v = 1 v = 4 v = 7 v = 10 v = 13 v = 16 v = 19 v = 22 v = 25 v = 28 v = 31 v = 34 v = 37 v = 40 v = 43 v = 46 v = 49 v = 52 v = 55 v = 58 v = 61 v = 64 v = 67 v = 70 v = 73 v = 76 v = 79 v = 82 v = 85 v = 88 v = 91 v = 94 v = 97 v = 100 v = 103 v = 106 v = 109 v = 112 v = 115 v = 118 v = 121 v = 124 v = 127 v = 130 v = 133 v = 136 v = 139 v = 142 v = 145 v = 148 v = 151 v = 154 v = 157 v = 160 v = 163 v = 166 v = 169 v = 172 v = 175 v = 178 v = 181 v = 184 v = 187 v = 190 v = 193 v = 196 v = 199 v = 202 v = 205 v = 208 v = 211 v = 214 v = 217 v = 220 v = 223 v = 226 v = 229 v = 232 v = 235 v = 238 v = 241 v = 244 v = 247 v = 250 v = 253 v = 256 v = 259 v = 262 v = 265 v = 268 v = 271 v = 274 v = 277 v = 280 v = 283 v = 286 v = 289 v = 292 v = 295 v = 298 v = 301 v = 304 v = 307 v = 310 v = 313 v = 316 v = 319 v = 322 v = 325 v = 328 v = 331 v = 334 v = 337 v = 340 v = 343 v = 346 v = 349 v = 352 v = 355 v = 358 v = 361 v = 364 v = 367 v = 370 v = 373 v = 376 v = 379 v = 382 v = 385 v = 388 v = 391 v = 394 v = 397 v = 400 v = 403 v = 406 v = 409 v = 412 v = 415 v = 418 v = 421 v = 424 v = 427 v = 430 v = 433 v = 436 v = 439 v = 442 v = 445 v = 448 v = 451 v = 454 v = 457 v = 460 v = 463 v = 466 v = 469 v = 472 v = 475 v = 478 v = 481 v = 484 v = 487 v = 490 v = 493 v = 496 v = 499 v = 502 v = 505 v = 508 v = 511 v = 514 v = 517 v = 520 v = 523 v = 526 v = 529 v = 532 v = 535 v = 538 v = 541 v = 544 v = 547 v = 550 v = 553 v = 556 v = 559 v = 562 v = 565 v = 568 v = 571 v = 574 v = 577 v = 580 v = 583 v = 586 v = 589 v = 592 v = 595 v = 598 v = 601 v = 604 v = 607 v = 610 v = 613 v = 616 v = 619 v = 622 v = 625 v = 628 v = 631 v = 634 v = 637 v = 640 v = 643 v = 646 v = 649 v = 652 v = 655 v = 658 v = 661 v = 664 v = 667 v = 670 v = 673 v = 676 v = 679 v = 682 v = 685 v = 688 v = 691 v = 694 v = 697 v = 700 v = 703 v = 706 v = 709 v = 712 v = 715 v = 718 v = 721 v = 724 v = 727 v = 730 v = 733 v = 736 v = 739 v = 742 v = 745 v = 748 v = 751 v = 754 v = 757 v = 760 v = 763 v = 766 v = 769 v = 772 v = 775 v = 778 v = 781 v = 784 v = 787 v = 790 v = 793 v = 796 v = 799 v = 802 v = 805 v = 808 v = 811 v = 814 v = 817 v = 820 v = 823 v = 826 v = 829 v = 832 v = 835 v = 838 v = 841 v = 844 v = 847 v = 850 v = 853 v = 856 v = 859 v = 862 v = 865 v = 868 v = 871 v = 874 v = 877 v = 880 v = 883 v = 886 v = 889 v = 892 v = 895 v = 898 v = 901 v = 904 v = 907 v = 910 v = 913 v = 916 v = 919 v = 922 v = 925 v = 928 v = 931 v = 934 v = 937 v = 940 v = 943 v = 946 v = 949 v = 952 v = 955 v = 958 v = 961 v = 964 v = 967 v = 970 v = 973 v = 976 v = 979 v = 982 v = 985 v = 988 v = 991 v = 994 v = 997 v = 1000 v = 1003 v = 1006 v = 1009 v = 1012 v = 1015 v = 1018 v = 1021 v = 1024 v = 1027 v = 1030 v = 1033 v = 1036 v = 1039 v = 1042 v = 1045 v = 1048 v = 1051 v = 1054 v = 1057 v = 1060 v = 1063 v = 1066 v = 1069 v = 1072 v = 1075 v = 1078 v = 1081 v = 1084 v = 1087 v = 1090 v = 1093 v = 1096 v = 1099 v = 1102 v = 1105 v = 1108 v = 1111 v = 1114 v = 1117 v = 1120 v = 1123 v = 1126 v = 1129 v = 1132 v = 1135 v = 1138 v = 1141 v = 1144 v = 1147 v = 1150 v = 1153 v = 1156 v = 1159 v = 1162 v = 1165 v = 1168 v = 1171 v = 1174 v = 1177 v = 1180 v = 1183 v = 1186 v = 1189 v = 1192 v = 1195 v = 1198 v = 1201 v = 1204 v = 1207 v = 1210 v = 1213 v = 1216 v = 1219 v = 1222 v = 1225 v = 1228 v = 1231 v = 1234 v = 1237 v = 1240 v = 1243 v = 1246 v = 1249 v = 1252 v = 1255 v = 1258 v = 1261 v = 1264 v = 1267 v = 1270 v = 1273 v = 1276 v = 1279 v = 1282 v = 1285 v = 1288 v = 1291 v = 1294 v = 1297 v = 1300 v = 1303 v = 1306 v = 1309 v = 1312 v = 1315 v = 1318 v = 1321 v = 1324 v = 1327 v = 1330 v = 1333 v = 1336 v = 1339 v = 1342 v = 1345 v = 1348 v = 1351 v = 1354 v = 1357 v = 1360 v = 1363 v = 1366 v = 1369 v = 1372 v = 1375 v = 1378 v = 1381 v = 1384 v = 1387 v = 1390 v = 1393 v = 1396 v = 1399 v = 1402 v = 1405 v = 1408 v = 1411 v = 1414 v = 1417 v = 1420 v = 1423 v = 1426 v = 1429 v = 1432 v = 1435 v = 1438 v = 1441 v = 1444 v = 1447 v = 1450 v = 1453 v = 1456 v = 1459 v = 1462 v = 1465 v = 1468 v = 1471 v = 1474 v = 1477 v = 1480 v = 1483 v = 1486 v = 1489 v = 1492 v = 1495 v = 1498 v = 1501 v = 1504 v = 1507 v = 1510 v = 1513 v = 1516 v = 1519 v = 1522 v = 1525 v = 1528 v = 1531 v = 1534 v = 1537 v = 1540 v = 1543 v = 1546 v = 1549 v = 1552 v = 1555 v = 1558 v = 1561 v = 1564 v = 1567 v = 1570 v = 1573 v = 1576 v = 1579 v = 1582 v = 1585 v = 1588 v = 1591 v = 1594 v = 1597 v = 1600 v = 1603 v = 1606 v = 1609 v = 1612 v = 1615 v = 1618 v = 1621 v = 1624 v = 1627 v = 1630 v = 1633 v = 1636 v = 1639 v = 1642 v = 1645 v = 1648 v = 1651 v = 1654 v = 1657 v = 1660 v = 1663 v = 1666 v = 1669 v = 1672 v = 1675 v = 1678 v = 1681 v = 1684 v = 1687 v = 1690 v = 1693 v = 1696 v = 1699 v = 1702 v = 1705 v = 1708 v = 1711 v = 1714 v = 1717 v = 1720 v = 1723 v = 1726 v = 1729 v = 1732 v = 1735 v = 1738 v = 1741 v = 1744 v = 1747 v = 1750 v = 1753 v = 1756 v = 1759 v = 1762 v = 1765 v = 1768 v = 1771 v = 1774 v = 1777 v = 1780 v = 1783 v = 1786 v = 1789 v = 1792 v = 1795 v = 1798 ...