Cody

Problem 42488. combine cells

Solution 1528474

Submitted on 14 May 2018
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
filetext = fileread('combineCells.m'); assert(isempty(strfind(filetext, 'for'))) assert(isempty(strfind(filetext, 'while')))

2   Fail
x = {{'cody';'players'};{'are';'great'}}; y_correct = {'cody';'players';'are';'great'}; assert(isequal(combineCells(x),y_correct))

Error using reshape To RESHAPE the number of elements must not change. Error in combineCells (line 2) reshape([x{:}],numel(x),1); Error in Test2 (line 3) assert(isequal(combineCells(x),y_correct))

3   Fail
x = {{'A';'B';'C'};{'D';'E'};{'F';'G';'H';'I';'J'}}; y_correct = {'A';'B';'C';'D';'E';'F';'G';'H';'I';'J'}; assert(isequal(combineCells(x),y_correct))

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in combineCells (line 2) reshape([x{:}],numel(x),1); Error in Test3 (line 3) assert(isequal(combineCells(x),y_correct))

4   Fail
x = {{'A';'B';'C'};{'D';'E'};{'F';'G';'H';'I';'J';'K'}}; y_correct = {'A';'B';'C';'D';'E';'F';'G';'H';'I';'J';'K'}; assert(isequal(combineCells(x),y_correct))

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in combineCells (line 2) reshape([x{:}],numel(x),1); Error in Test4 (line 3) assert(isequal(combineCells(x),y_correct))

5   Fail
x = {{'A';'B';'C';'toPreventLittleCheats'};{'D';'E'};{'F';'G';'H';'I';'J'}}; y_correct = {'A';'B';'C';'toPreventLittleCheats';'D';'E';'F';'G';'H';'I';'J'}; assert(isequal(combineCells(x),y_correct))

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in combineCells (line 2) reshape([x{:}],numel(x),1); Error in Test5 (line 3) assert(isequal(combineCells(x),y_correct))