Cody

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

Solution 1980182

Submitted on 17 Oct 2019
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))

x = '[l]eft3down2' x = '[l][e]ft3down2' x = '[l][e][f]t3down2' x = '[l][e][f][t3]down2' x = '[l][e][f][t3][d]own2' x = '[l][e][f][t3][d][o]wn2' x = '[l][e][f][t3][d][o][w]n2' x = '[l][e][f][t3][d][o][w][n2]' y = '[l][e][f][t3][d][o][w][n2]'

Assertion failed.

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

x = '[f]iat500' x = '[f][i]at500' x = '[f][i][a]t500' x = '[f][i][a][t500]' y = '[f][i][a][t500]'

Assertion failed.

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

x = '[n]o [n]umbers here' x = '[n][o] [n]umbers here' x = '[n][o][][n]umbers[]here' x = '[[n]][o][][[n]]umbers[]here' x = '[[n]][o][][[n]][u]mbers[]here' x = '[[n]][o][][[n]][u][m]bers[]here' x = '[[n]][o][][[n]][u][m][b]ers[]here' x = '[[n]][o][][[n]][u][m][b][e]rs[]h[e]r[e]' x = '[[n]][o][][[n]][u][m][b][e][r]s[]h[e][r][e]' x = '[[n]][o][][[n]][u][m][b][e][r][s][]h[e][r][e]' x = '[[n]][o][][[n]][u][m][b][e][r][s][]h[e][r][e]' x = '[[n]][o][][[n]][u][m][b][e][r][s][][h][e][r][e]' x = '[[n]][o][][[n]][u][m][b][[e]][r][s][][h][[e]][r][[e]]' x = '[[n]][o][][[n]][u][m][b][[e]][[r]][s][][h][[e]][[r]][[e]]' x = '[[n]][o][][[n]][u][m][b][[[e]]][[r]][s][][h][[[e]]][[r]][[[e]]]' y = '[[n]][o][][[n]][u][m][b][[[e]]][[r]][s][][h][[[e]]][[r]][[[e]]]'

Assertion failed.

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

y = '1234567890'

Assertion failed.

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))

x = '[v]ar1 = 20; [v]ar2 = 47; [v]ar3 = 59;' x = '[v][a]r1 = 20; [v][a]r2 = 47; [v][a]r3 = 59;' x = '[v][a][r1] = 20; [v][a]r2 = 47; [v][a]r3 = 59;' x = '[v][a][r1][]=[]20;[][v][a]r2[]=[]47;[][v][a]r3[]=[]59;' x = '[v][a][r1][][=][]20;[][v][a]r2[][=][]47;[][v][a]r3[][=][]59;' x = '[v][a][r1][][=][]20;[][v][a]r2[][=][]47;[][v][a]r3[][=][]59;' x = '[v][a][r1][][=][]20[;][][v][a]r2[][=][]47[;][][v][a]r3[][=][]59[;]' x = '[v][a][r1][][=][]20[;][][v][a]r2[][=][]47[;][][v][a]r3[][=][]59[;]' x = '[[v]][a][r1][][=][]20[;][][[v]][a]r2[][=][]47[;][][[v]][a]r3[][=][]59[;]' x = '[[v]][[a]][r1][][=][]20[;][][[v]][[a]]r2[][=][]47[;][][[v]][[a]]r3[][=][]59[;]' x = '[[v]][[a]][r1][][=][]20[;][][[v]][[a]][r2][][=][]47[;][][[v]][[a]]r3[][=][]59[;]' x = '[[v]][[a]][r1][][=][]20[;][][[v]][[a]][r2][][=][]47[;][][[v]][[a]]r3[][=][]59[;]' x = '[[v]][[a]][r1][][[=]][]20[;][][[v]][[a]][r2][][[=]][]47[;][][[v]][[a]]r3[][[=]][]59[;]' x = '[[v]][[a]][r1][][[=]][]20[;][][[v]][[a]][r2][][[=]][]47[;][][[v]][[a]]r3[][[=]][]59[;]' x = '[[v]][[a]][r1][][[=]][]20[[;]][][[v]][[a]][r2][][[=]][]47[[;]][][[v]][[a]]r3[][[=]][]59[[;]]' x = '[[v]][[a]][r1][][[=]][]20[[;]][][[v]][[a]][r2][][[=]][]47[[;]][][[v]][[a]]r3[][[=]][]59[[;]]' x = '[[[v]]][[a]][r1][][[=]][]20[[;]][][[[v]]][[a]][r2][][[=]][]47[[;]][][[[v]]][[a]]r3[][[=]][]59[[;]]' x = '[[[v]]][[[a]]][r1][][[=]][]20[[;]][][[[v]]][[[a]]][r2][][[=]][]47[[;]][][[[v]]][[[a]]]r3[][[=]][]59[[;]]' x = '[[[v]]][[[a]]][r1][][[=]][]20[[;]][][[[v]]][[[a]]][r2][][[=]][]47[[;]][][[[v]]][[[a]]][r3][][[=]][]59[[;]]' x = '[[[v]]][[[a]]][r1][][[=]][]20[[;]][][[[v]]][[[a]]][r2][][[=]][]47[[;]][][[[v]]][[[a]]][r3][][[=]][]59[[;]]' x = '[[[v]]][[[a]]][r1][][[[=]]][]20[[;]][][[[v]]][[[a]]][r2][][[[=]]][]47[[;]][][[[v]]][[[a]]][r3][][[[=]]][]59[[;]]' x = '[[[v]]][[[a]]][r1][][[[=]]][]20[[;]][][[[v]]][[[a]]][r2][][[[=]]][]47[[;]][][[[v]]][[[a]]][r3][][[[=]]][]59[[;]]' x = '[[[v]]][[[a]]][r1][][[[=]]][]20[[[;]]][][[[v]]][[[a]]][r2][][[[=]]][]47[[[;]]][][[[v]]][[[a]]][r3][][[[=]]][]59[[[;]]]' y = '[[[v]]][[[a]]][r1][][[[=]]][]20[[[;]]][][[[v]]][[[a]]][r2][][[[=]]][]47[[[;]]][][[[v]]][[[a]]][r3][][[[=]]][]59[[[;]]]'

Assertion failed.

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

x = '14[e]t38z1n541z8n[e]' x = '14[e][t38]z1n541z8n[e]' x = '14[e][t38][z1]n541z8n[e]' x = '14[e][t38][z1][n541]z8n[e]' x = '14[e][t38][z1][n541][z8]n[e]' x = '14[e][t38][z1][[n]541][z8][n][e]' x = '14[[e]][t38][z1][[n]541][z8][n][[e]]' y = '14[[e]][t38][z1][[n]541][z8][n][[e]]'

Assertion failed.