Cody

Solution 2031389

Submitted on 22 Nov 2019 by Eugene Kronberg
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()))

z = 0 q = 1 z = 1 q = 1 z = 2 q = 1 z = 3 q = 1

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

z = 1 q = 0 z = 1 q = 0 z = 1 q = 0 z = 1 q = 0

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

z = 10 q = 2 z = 12 q = 2 z = 14 q = 2 z = 16 q = 2

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

z = 0 q = 5 z = 5 q = 5 z = 10 q = 5 z = 15 q = 5 z = 20 q = 5 z = 25 q = 5 z = 30 q = 5

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

z = 8 q = 3 z = 11 q = 3 z = 14 q = 3 z = 17 q = 3 z = 20 q = 3 z = 23 q = 3 z = 26 q = 3 z = 29 q = 3 z = 32 q = 3 z = 35 q = 3 z = 38 q = 3 z = 41 q = 3 z = 44 q = 3 z = 47 q = 3 z = 50 q = 3 z = 53 q = 3 z = 56 q = 3 z = 59 q = 3 z = 62 q = 3 z = 65 q = 3 z = 68 q = 3 z = 71 q = 3 z = 74 q = 3 z = 77 q = 3 z = 80 q = 3 z = 83 q = 3 z = 86 q = 3 z = 89 q = 3 z = 92 q = 3 z = 95 q = 3 z = 98 q = 3 z = 101 q = 3 z = 104 q = 3 z = 107 q = 3 z = 110 q = 3 z = 113 q = 3 z = 116 q = 3 z = 119 q = 3 z = 122 q = 3 z = 125 q = 3 z = 128 q = 3 z = 131 q = 3 z = 134 q = 3 z = 137 q = 3 z = 140 q = 3 z = 143 q = 3 z = 146 q = 3 z = 149 q = 3 z = 152 q = 3 z = 155 q = 3 z = 158 q = 3 z = 161 q = 3 z = 164 q = 3 z = 167 q = 3 z = 170 q = 3 z = 173 q = 3 z = 176 q = 3 z = 179 q = 3 z = 182 q = 3 z = 185 q = 3 z = 188 q = 3 z = 191 q = 3 z = 194 q = 3 z = 197 q = 3 z = 200 q = 3 z = 203 q = 3 z = 206 q = 3 z = 209 q = 3 z = 212 q = 3 z = 215 q = 3 z = 218 q = 3 z = 221 q = 3 z = 224 q = 3 z = 227 q = 3 z = 230 q = 3 z = 233 q = 3 z = 236 q = 3 z = 239 q = 3 z = 242 q = 3 z = 245 q = 3 z = 248 q = 3 z = 251 q = 3 z = 254 q = 3 z = 257 q = 3 z = 260 q = 3 z = 263 q = 3 z = 266 q = 3 z = 269 q = 3 z = 272 q = 3 z = 275 q = 3 z = 278 q = 3 z = 281 q = 3 z = 284 q = 3 z = 287 q = 3 z = 290 q = 3 z = 293 q = 3 z = 296 q = 3 z = 299 q = 3 z = 302 q = 3 z = 305 q = 3 z = 308 q = 3 z = 311 q = 3 z = 314 q = 3 z = 317 q = 3 z = 320 q = 3 z = 323 q = 3 z = 326 q = 3 z = 329 q = 3 z = 332 q = 3 z = 335 q = 3 z = 338 q = 3 z = 341 q = 3 z = 344 q = 3 z = 347 q = 3 z = 350 q = 3 z = 353 q = 3 z = 356 q = 3 z = 359 q = 3 z = 362 q = 3 z = 365 q = 3 z = 368 q = 3 z = 371 q = 3 z = 374 q = 3 z = 377 q = 3 z = 380 q = 3 z = 383 q = 3 z = 386 q = 3 z = 389 q = 3 z = 392 q = 3 z = 395 q = 3 z = 398 q = 3 z = 401 q = 3 z = 404 q = 3 z = 407 q = 3 z = 410 q = 3 z = 413 q = 3 z = 416 q = 3 z = 419 q = 3 z = 422 q = 3 z = 425 q = 3 z = 428 q = 3 z = 431 q = 3 z = 434 q = 3 z = 437 q = 3 z = 440 q = 3 z = 443 q = 3 z = 446 q = 3 z = 449 q = 3 z = 452 q = 3 z = 455 q = 3 z = 458 q = 3 z = 461 q = 3 z = 464 q = 3 z = 467 q = 3 z = 470 q = 3 z = 473 q = 3 z = 476 q = 3 z = 479 q = 3 z = 482 q = 3 z = 485 q = 3 z = 488 q = 3 z = 491 q = 3 z = 494 q = 3 z = 497 q = 3 z = 500 q = 3 z = 503 q = 3 z = 506 q = 3 z = 509 q = 3 z = 512 q = 3 z = 515 q = 3 z = 518 q = 3 z = 521 q = 3 z = 524 q = 3 z = 527 q = 3 z = 530 q = 3 z = 533 q = 3 z = 536 q = 3 z = 539 q = 3 z = 542 q = 3 z = 545 q = 3 z = 548 q = 3 z = 551 q = 3 z = 554 q = 3 z = 557 q = 3 z = 560 q = 3 z = 563 q = 3 z = 566 q = 3 z = 569 q = 3 z = 572 q = 3 z = 575 q = 3 z = 578 q = 3 z = 581 q = 3 z = 584 q = 3 z = 587 q = 3 z = 590 q = 3 z = 593 q = 3 z = 596 q = 3 z = 599 q = 3 z = 602 q = 3 z = 605 q = 3 z = 608 q = 3 z = 611 q = 3 z = 614 q = 3 z = 617 q = 3 z = 620 q = 3 z = 623 q = 3 z = 626 q = 3 z = 629 q = 3 z = 632 q = 3 z = 635 q = 3 z = 638 q = 3 z = 641 q = 3 z = 644 q = 3 z = 647 q = 3 z = 650 q = 3 z = 653 q = 3 z = 656 q = 3 z = 659 q = 3 z = 662 q = 3 z = 665 q = 3 z = 668 q = 3 z = 671 q = 3 z = 674 q = 3 z = 677 q = 3 z = 680 q = 3 z = 683 q = 3 z = 686 q = 3 z = 689 q = 3 z = 692 q = 3 z = 695 q = 3 z = 698 q = 3 z = 701 q = 3 z = 704 q = 3 z = 707 q = 3 z = 710 q = 3 z = 713 q = 3 z = 716 q = 3 z = 719 q = 3 z = 722 q = 3 z = 725 q = 3 z = 728 q = 3 z = 731 q = 3 z = 734 q = 3 z = 737 q = 3 z = 740 q = 3 z = 743 q = 3 z = 746 q = 3 z = 749 q = 3 z = 752 q = 3 z = 755 q = 3 z = 758 q = 3 z = 761 q = 3 z = 764 q = 3 z = 767 q = 3 z = 770 q = 3 z = 773 q = 3 z = 776 q = 3 z = 779 q = 3 z = 782 q = 3 z = 785 q = 3 z = 788 q = 3 z = 791 q = 3 z = 794 q = 3 z = 797 q = 3 z = 800 q = 3 z = 803 q = 3 z = 806 q = 3 z = 809 q = 3 z = 812 q = 3 z = 815 q = 3 z = 818 q = 3 z = 821 q = 3 z = 824 q = 3 z = 827 q = 3 z = 830 q = 3 z = 833 q = 3 z = 836 q = 3 z = 839 q = 3 z = 842 q = 3 z = 845 q = 3 z = 848 q = 3 z = 851 q = 3 z = 854 q = 3 z = 857 q = 3 z = 860 q = 3 z = 863 q = 3 z = 866 q = 3 z = 869 q = 3 z = 872 q = 3 z = 875 q = 3 z = 878 q = 3 z = 881 q = 3 z = 884 q = 3 z = 887 q = 3 z = 890 q = 3 z = 893 q = 3 z = 896 q = 3 z = 899 q = 3 z = 902 q = 3 z = 905 q = 3 z = 908 q = 3 z = 911 q = 3 z = 914 q = 3 z = 917 q = 3 z = 920 q = 3 z = 923 q = 3 z = 926 q = 3 z = 929 q = 3 z = 932 q = 3 z = 935 q = 3 z = 938 q = 3 z = 941 q = 3 z = 944 q = 3 z = 947 q = 3 z = 950 q = 3 z = 953 q = 3 z = 956 q = 3 z = 959 q = 3 z = 962 q = 3 z = 965 q = 3 z = 968 q = 3 z = 971 q = 3 z = 974 q = 3 z = 977 q = 3 z = 980 q = 3 z = 983 q = 3 z = 986 q = 3 z = 989 q = 3 z = 992 q = 3 z = 995 q = 3 z = 998 q = 3 z = 1001 q = 3 z = 1004 q = 3 z = 1007 q = 3 z = 1010 q = 3 z = 1013 q = 3 z = 1016 q = 3 z = 1019 q = 3 z = 1022 q = 3 z = 1025 q = 3 z = 1028 q = 3 z = 1031 q = 3 z = 1034 q = 3 z = 1037 q = 3 z = 1040 q = 3 z = 1043 q = 3 z = 1046 q = 3 z = 1049 q = 3 z = 1052 q = 3 z = 1055 q = 3 z = 1058 q = 3 z = 1061 q = 3 z = 1064 ...