Cody

# Problem 43077. Put all numbers in a string inside square brackets

Solution 2165189

Submitted on 19 Mar 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 = 'left3down2'; y_correct = 'left[3]down[2]'; assert(strcmp(nestedNums(x),y_correct))

s = 1×10 cell array {'l'} {'e'} {'f'} {'t'} {'3'} {'d'} {'o'} {'w'} {'n'} {'2'}

Output argument "y" (and maybe others) not assigned during call to "nestedNums". Error in Test1 (line 3) assert(strcmp(nestedNums(x),y_correct))

2   Fail
x = 'fiat500'; y_correct = 'fiat[500]'; assert(strcmp(nestedNums(x),y_correct))

s = 1×5 cell array {'f'} {'i'} {'a'} {'t'} {'500'}

Output argument "y" (and maybe others) not assigned during call to "nestedNums". Error in Test2 (line 3) assert(strcmp(nestedNums(x),y_correct))

3   Fail
x = 'no numbers here'; y_correct = 'no numbers here'; assert(strcmp(nestedNums(x),y_correct))

s = 1×15 cell array {'n'} {'o'} {' '} {'n'} {'u'} {'m'} {'b'} {'e'} {'r'} {'s'} {' '} {'h'} {'e'} {'r'} {'e'}

Output argument "y" (and maybe others) not assigned during call to "nestedNums". Error in Test3 (line 3) assert(strcmp(nestedNums(x),y_correct))

4   Fail
x = '1234567890'; y_correct = '[1234567890]'; assert(strcmp(nestedNums(x),y_correct))

s = 1×1 cell array {'1234567890'}

Output argument "y" (and maybe others) not assigned during call to "nestedNums". Error in Test4 (line 3) assert(strcmp(nestedNums(x),y_correct))

5   Fail
x = 'var1 = 20; var2 = 47; var3 = 59;'; y_correct = 'var[1] = [20]; var[2] = [47]; var[3] = [59];'; assert(strcmp(nestedNums(x),y_correct))

s = 1×26 cell array Columns 1 through 19 {'v'} {'a'} {'r'} {'1'} {' '} {'='} {' 20'} {';'} {' '} {'v'} {'a'} {'r'} {'2'} {' '} {'='} {' 47'} {';'} {' '} {'v'} Columns 20 through 26 {'a'} {'r'} {'3'} {' '} {'='} {' 59'} {';'}

Output argument "y" (and maybe others) not assigned during call to "nestedNums". Error in Test5 (line 3) assert(strcmp(nestedNums(x),y_correct))

6   Fail
x = '14et38z1n541z8ne'; y_correct = '[14]et[38]z[1]n[541]z[8]ne'; assert(strcmp(nestedNums(x),y_correct))

s = 1×12 cell array {'14'} {'e'} {'t'} {'38'} {'z'} {'1'} {'n'} {'541'} {'z'} {'8'} {'n'} {'e'}

Output argument "y" (and maybe others) not assigned during call to "nestedNums". Error in Test6 (line 3) assert(strcmp(nestedNums(x),y_correct))