Cody

Problem 3004. Two functions (to be sure)

Solution 1028228

Submitted on 23 Oct 2016
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
x = 1; assert(isequal(odd_fcn(x),1)) assert(isequal(even_fcn(x),0))

Undefined function 'even_fcn' for input arguments of type 'double'. Error in TestPoint1 (line 3) assert(isequal(even_fcn(x),0))

2   Fail
y = 2; assert(isequal(odd_fcn(y),0)) assert(isequal(even_fcn(y),1))

Assertion failed.

3   Fail
x = [1 2]; assert(isequal(odd_fcn(x),1)) assert(isequal(even_fcn(x),1))

Undefined function 'even_fcn' for input arguments of type 'double'. Error in TestPoint3 (line 3) assert(isequal(even_fcn(x),1))

4   Fail
x = 1:10; assert(isequal(odd_fcn(x),5)) assert(isequal(even_fcn(x),5))

Assertion failed.

5   Fail
x = 1:100; assert(isequal(odd_fcn(x),50)) assert(isequal(even_fcn(x),50))

Assertion failed.

6   Fail
x=(2:2:1000)'; assert(isequal(odd_fcn(x),0)) assert(isequal(even_fcn(x),500))

Assertion failed.

7   Fail
x = [1:2:10000]; assert(isequal(odd_fcn(x),5000)) assert(isequal(even_fcn(x),0))

Assertion failed.

8   Fail
x = [2 1:2:10000]; assert(isequal(odd_fcn(x),5000)) assert(isequal(even_fcn(x),1))

Assertion failed.

9   Fail
x = [1 2 3;4 5 6;7 8 9]; assert(isequal(odd_fcn(x),5)) assert(isequal(even_fcn(x),4))

Assertion failed.

Suggested Problems

More from this Author43

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!