Cody

# Problem 1579. How many digits are there?

Solution 3746848

Submitted on 20 Nov 2020 by Tahmina Tabassum Treena
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
x = 'anbduybefiafn29128r4 ybzw'; y_correct = 6; assert(isequal(digits(x),y_correct))

p = 0 1 2 3 4 5 6 7 8 9 c = 1 c = 2 c = 3 c = 4 c = 5 c = 6 y = 6

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

p = 0 1 2 3 4 5 6 7 8 9 c = 1 c = 2 c = 3 c = 4 c = 5 c = 6 c = 7 y = 7

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

p = 0 1 2 3 4 5 6 7 8 9 c = 1 c = 2 c = 3 c = 4 c = 5 c = 6 c = 7 c = 8 c = 9 c = 10 y = 10

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

p = 0 1 2 3 4 5 6 7 8 9 c = 1 c = 2 c = 3 c = 4 c = 5 c = 6 c = 7 c = 8 c = 9 y = 9

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

p = 0 1 2 3 4 5 6 7 8 9 c = 1 c = 2 c = 3 c = 4 c = 5 c = 6 c = 7 c = 8 c = 9 c = 10 c = 11 c = 12 c = 13 c = 14 c = 15 c = 16 c = 17 c = 18 y = 18

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

p = 0 1 2 3 4 5 6 7 8 9 c = 1 c = 2 c = 3 c = 4 c = 5 c = 6 c = 7 c = 8 c = 9 c = 10 c = 11 c = 12 c = 13 c = 14 c = 15 c = 16 c = 17 c = 18 c = 19 c = 20 c = 21 c = 22 c = 23 c = 24 c = 25 c = 26 c = 27 c = 28 c = 29 c = 30 c = 31 c = 32 c = 33 c = 34 c = 35 c = 36 c = 37 c = 38 c = 39 c = 40 c = 41 c = 42 c = 43 c = 44 c = 45 c = 46 c = 47 c = 48 c = 49 c = 50 c = 51 c = 52 c = 53 c = 54 c = 55 c = 56 c = 57 c = 58 c = 59 c = 60 c = 61 c = 62 c = 63 c = 64 c = 65 c = 66 c = 67 c = 68 c = 69 c = 70 c = 71 c = 72 c = 73 c = 74 c = 75 c = 76 c = 77 c = 78 c = 79 c = 80 c = 81 c = 82 c = 83 c = 84 c = 85 c = 86 c = 87 c = 88 c = 89 c = 90 c = 91 c = 92 c = 93 c = 94 c = 95 c = 96 c = 97 c = 98 c = 99 c = 100 c = 101 c = 102 c = 103 c = 104 c = 105 c = 106 c = 107 c = 108 c = 109 c = 110 c = 111 c = 112 c = 113 c = 114 c = 115 c = 116 c = 117 c = 118 c = 119 c = 120 c = 121 c = 122 c = 123 c = 124 c = 125 c = 126 c = 127 c = 128 c = 129 c = 130 c = 131 c = 132 c = 133 c = 134 c = 135 c = 136 c = 137 c = 138 c = 139 c = 140 c = 141 c = 142 c = 143 c = 144 c = 145 c = 146 c = 147 c = 148 c = 149 c = 150 c = 151 c = 152 c = 153 c = 154 c = 155 c = 156 c = 157 c = 158 c = 159 c = 160 c = 161 c = 162 c = 163 c = 164 c = 165 c = 166 c = 167 c = 168 c = 169 c = 170 c = 171 c = 172 c = 173 c = 174 c = 175 c = 176 c = 177 c = 178 c = 179 c = 180 c = 181 c = 182 c = 183 c = 184 c = 185 c = 186 c = 187 c = 188 c = 189 c = 190 c = 191 c = 192 y = 192

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

p = 0 1 2 3 4 5 6 7 8 9 c = 1 c = 2 y = 2

### Community Treasure Hunt

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

Start Hunting!