Cody

Problem 41. Cell joiner

Solution 2130756

Submitted on 16 Feb 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 = {'hello', 'basic', 'test', 'case'}; y_correct = 'hello basic test case'; assert(isequal(cellstr_joiner(x, ' '),y_correct))

x = 1×4 cell array {'hello'} {'basic'} {'test'} {'case'} delim = ' '

Error using strsplit (line 80) First input must be either a character vector or a string scalar. Error in cellstr_joiner (line 4) out_str = strsplit(x,delim) Error in Test1 (line 3) assert(isequal(cellstr_joiner(x, ' '),y_correct))

2   Fail
x = {'this', 'one', '', 'has', ' ', 'some tricky', 'stuff'}; y_correct = 'this one has some tricky stuff'; assert(isequal(cellstr_joiner(x, ' '),y_correct))

x = 1×7 cell array {'this'} {'one'} {0×0 char} {'has'} {' '} {'some tricky'} {'stuff'} delim = ' '

Error using strsplit (line 80) First input must be either a character vector or a string scalar. Error in cellstr_joiner (line 4) out_str = strsplit(x,delim) Error in Test2 (line 3) assert(isequal(cellstr_joiner(x, ' '),y_correct))

3   Fail
x = {'delimiters', 'are', 'not', 'always', 'spaces'}; y_correct = 'delimiters?are?not?always?spaces'; assert(isequal(cellstr_joiner(x, '?'),y_correct))

x = 1×5 cell array {'delimiters'} {'are'} {'not'} {'always'} {'spaces'} delim = ' '

Error using strsplit (line 80) First input must be either a character vector or a string scalar. Error in cellstr_joiner (line 4) out_str = strsplit(x,delim) Error in Test3 (line 3) assert(isequal(cellstr_joiner(x, '?'),y_correct))