Cody

Problem 1579. How many digits are there?

Solution 2018348

Submitted on 13 Nov 2019 by Asif Newaz
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))

a = 14 15 16 17 18 20 n = 6

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

a = 5 6 8 18 19 23 31 n = 7

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

a = 1 2 3 4 5 6 7 8 9 10 n = 10

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

a = 2 4 6 8 10 12 14 16 18 n = 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))

a = 6 7 8 9 10 11 12 13 28 29 38 39 41 42 49 55 62 63 n = 18

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

a = Columns 1 through 30 1 6 11 16 21 26 31 36 41 45 46 50 51 55 56 60 61 65 66 70 71 75 76 80 81 85 86 90 91 95 Columns 31 through 60 96 100 101 105 106 110 111 115 116 120 121 125 126 130 131 135 136 140 141 145 146 150 151 155 156 160 161 165 166 170 Columns 61 through 90 171 175 176 180 181 185 186 190 191 195 196 200 201 205 206 210 211 215 216 220 221 225 226 230 231 235 236 240 241 245 Columns 91 through 120 246 250 251 255 256 260 261 265 266 270 271 275 276 280 281 285 286 290 291 295 296 300 301 305 306 310 311 315 316 320 Columns 121 through 150 321 325 326 330 331 335 336 340 341 345 346 350 351 355 356 360 361 365 366 370 371 375 376 380 381 385 386 390 391 395 Columns 151 through 180 396 400 401 405 406 410 411 415 416 420 421 425 426 430 431 435 436 440 441 445 446 450 451 455 456 460 461 465 466 470 Columns 181 through 192 471 475 476 480 481 485 486 490 491 494 495 496 n = 192

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

a = 15 16 n = 2