Cody

# Problem 1579. How many digits are there?

Solution 3148791

Submitted on 10 Oct 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
x = 'anbduybefiafn29128r4 ybzw'; y_correct = 6; assert(isequal(digits(x),y_correct))

Unrecognized function or variable 'st'. Error in digits (line 2) n = length(strsplit(s(~isletter(st))))-1; Error in Test1 (line 3) assert(isequal(digits(x),y_correct))

2   Fail
x = 'anuk32y7rhcscbniv82 bv7hf bA^#2tR*Gqvg'; y_correct = 7; assert(isequal(digits(x),y_correct))

Unrecognized function or variable 'st'. Error in digits (line 2) n = length(strsplit(s(~isletter(st))))-1; Error in Test2 (line 3) assert(isequal(digits(x),y_correct))

3   Fail
x = '1234567890'; y_correct = 10; assert(isequal(digits(x),y_correct))

Unrecognized function or variable 'st'. Error in digits (line 2) n = length(strsplit(s(~isletter(st))))-1; Error in Test3 (line 3) assert(isequal(digits(x),y_correct))

4   Fail
x = 'a1b2c3d4e5f6g7h8i9'; y_correct = 9; assert(isequal(digits(x),y_correct))

Unrecognized function or variable 'st'. Error in digits (line 2) n = length(strsplit(s(~isletter(st))))-1; Error in Test4 (line 3) assert(isequal(digits(x),y_correct))

5   Fail
x = 's;dfj98798324k kds \$:J(%*n 34 ;ljkasr87 34w ;lkj3 aoij5l;j;q 35'; y_correct = 18; assert(isequal(digits(x),y_correct))

Unrecognized function or variable 'st'. Error in digits (line 2) n = length(strsplit(s(~isletter(st))))-1; Error in Test5 (line 3) assert(isequal(digits(x),y_correct))

6   Fail
x = num2str(1:100); y_correct = 192; assert(isequal(digits(x),y_correct))

Unrecognized function or variable 'st'. Error in digits (line 2) n = length(strsplit(s(~isletter(st))))-1; Error in Test6 (line 3) assert(isequal(digits(x),y_correct))

7   Fail
x = 'The answer is 42.'; y_correct = 2; assert(isequal(digits(x),y_correct))

Unrecognized function or variable 'st'. Error in digits (line 2) n = length(strsplit(s(~isletter(st))))-1; Error in Test7 (line 3) assert(isequal(digits(x),y_correct))

### Community Treasure Hunt

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

Start Hunting!