Cody

# Problem 288. Construct a string from letters and counts

Solution 1915680

Submitted on 29 Aug 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 = []; y = []; y_correct = 'ERROR'; assert(isequal(construct_string(x,y),y_correct))

Matrix dimensions must agree. Error in construct_string (line 16) if class(lengths)=='char' Error in Test1 (line 3) assert(isequal(construct_string(x,y),y_correct))

2   Fail
x = [-1]; y = ['a']; y_correct = 'ERROR'; assert(isequal(construct_string(x,y),y_correct))

y = 'ERROR'

Matrix dimensions must agree. Error in construct_string (line 16) if class(lengths)=='char' Error in Test2 (line 3) assert(isequal(construct_string(x,y),y_correct))

3   Pass
x = ['a']; y = [5]; y_correct = 'ERROR'; assert(isequal(construct_string(x,y),y_correct))

y = 'ERROR'

4   Fail
r = 10+randi(20); x = [r 1]; y = 'ab'; y_correct(1:r) = 'a'; y_correct(r+1) = 'b'; assert(isequal(construct_string(x,y),y_correct))

Matrix dimensions must agree. Error in construct_string (line 16) if class(lengths)=='char' Error in Test4 (line 3) assert(isequal(construct_string(x,y),y_correct))

5   Fail
x = [5 4 3 2 1]; y = '.#4a5'; y_correct = '.....####444aa5'; assert(isequal(construct_string(x,y),y_correct))

Matrix dimensions must agree. Error in construct_string (line 16) if class(lengths)=='char' Error in Test5 (line 4) assert(isequal(construct_string(x,y),y_correct))

6   Fail
x1 = [1 1 1 1 1 1]; y = 'banana'; assert(isequal(construct_string(x1,y),y))

Matrix dimensions must agree. Error in construct_string (line 16) if class(lengths)=='char' Error in Test6 (line 3) assert(isequal(construct_string(x1,y),y))