Cody

# Problem 44345. MATLAB Counter

Solution 2129294

Submitted on 15 Feb 2020
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   Fail
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','counter.m')

Error in solution: Line: 2 Column: 9 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 9 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 9 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 9 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 9 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

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

Error in solution: Line: 2 Column: 9 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.