Cody

# Problem 44454. How many Integers?

Solution 2289368

Submitted on 17 May 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   Pass
filetext = fileread('integerCount.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Fail
v = [1.6, 5.7, 8, -3, 5.3, 9.0, -1, 0, 12] n_correct = 6; assert(isequal(integerCount(v),n_correct))

v = 1.6000 5.7000 8.0000 -3.0000 5.3000 9.0000 -1.0000 0 12.0000

Unrecognized function or variable 'i'. Error in integerCount (line 2) n=0; a=v(i); i=1; Error in Test2 (line 3) assert(isequal(integerCount(v),n_correct))

3   Fail
v = [1.6, 5.7, 4.8, -3.5, 5.3, 9.2, -1.1, 0.01, 1.2] n_correct = 0; assert(isequal(integerCount(v),n_correct))

v = 1.6000 5.7000 4.8000 -3.5000 5.3000 9.2000 -1.1000 0.0100 1.2000

Unrecognized function or variable 'i'. Error in integerCount (line 2) n=0; a=v(i); i=1; Error in Test3 (line 3) assert(isequal(integerCount(v),n_correct))

4   Fail
v = [] n_correct = 0; assert(isequal(integerCount(v),n_correct))

v = []

Unrecognized function or variable 'i'. Error in integerCount (line 2) n=0; a=v(i); i=1; Error in Test4 (line 3) assert(isequal(integerCount(v),n_correct))

### Community Treasure Hunt

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

Start Hunting!