Cody

# Problem 2216. Given an input string, generate a variable name out of it

Solution 2645167

Submitted on 2 Jul 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   Pass
x= 'this is an input var'; y_correct = 'thisIsAnInputVar'; assert(isequal(InputVarName(x),y_correct));

str1 = 'this is an input var' str = 'this is an input var' idx = 1 6 9 12 18 str = 'This Is An Input Var' str = 'this Is An Input Var' y = 'thisIsAnInputVar' y = 'thisIsAnInputVar' y = 'thisIsAnInputVar' y = 'thisIsAnInputVar'

2   Pass
x= 'this one has special char @123'; y_correct = 'thisOneHasSpecialChar_123'; assert(isequal(InputVarName(x),y_correct));

str1 = 'this one has special char @123' str = 'this one has special char @123' idx = 1 6 10 14 22 27 str = 'This One Has Special Char @123' str = 'this One Has Special Char @123' y = 'thisOneHasSpecialChar@123' y = 'thisOneHasSpecialChar_123' y = 'thisOneHasSpecialChar_123' y = 'thisOneHasSpecialChar_123'

3   Fail
x= 'RealInput Variable !!'; y_correct = 'RealInputVariable__'; assert(isequal(InputVarName(x),y_correct));

str1 = 'RealInput Variable !!' str = 'realinput variable !!' idx = 1 11 20 str = 'Realinput Variable !!' str = 'Realinput Variable !!' y = 'RealinputVariable!!' y = 'RealinputVariable!!' y = 'RealinputVariable__' y = 'RealinputVariable__'

Assertion failed.

4   Pass
x= 'This^is^fun^23^45^too'; y_correct = 'This_is_fun_23_45_too'; assert(isequal(InputVarName(x),y_correct));

str1 = 'This^is^fun^23^45^too' str = 'this^is^fun^23^45^too' idx = 1 str = 'This^is^fun^23^45^too' str = 'This^is^fun^23^45^too' y = 'This^is^fun^23^45^too' y = 'This^is^fun^23^45^too' y = 'This^is^fun^23^45^too' y = 'This_is_fun_23_45_too'