Cody

# Problem 967. Split a string into chunks of specified length

Solution 2831928

Submitted on 14 Aug 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
s = 'Easy'; b = ones(1,4); y_correct = {'E','a','s','y'}; assert(isequal(break_string(s,b),y_correct))

c = 4×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} c = 4×1 cell array {'E' } {0×0 double} {0×0 double} {0×0 double} n = 2 c = 4×1 cell array {'E' } {1×0 char } {0×0 double} {0×0 double} n = 3 c = 4×1 cell array {'E' } {1×0 char } {1×0 char } {0×0 double} n = 4 c = 4×1 cell array {'E' } {1×0 char} {1×0 char} {1×0 char} n = 5

Assertion failed.

2   Fail
s = 'I seem to be having tremendous difficulty with my lifestyle'; b = [4 1 5 22]; y_correct = {'I se','e','m to ','be having tremendous d'}; assert(isequal(break_string(s,b),y_correct))

c = 4×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} c = 4×1 cell array {'I se' } {0×0 double} {0×0 double} {0×0 double} n = 5 c = 4×1 cell array {'I se' } {1×0 char } {0×0 double} {0×0 double} n = 6 c = 4×1 cell array {'I se' } {1×0 char } {1×0 char } {0×0 double} n = 11 c = 4×1 cell array {'I se' } {1×0 char } {1×0 char } {'be having tr'} n = 33

Assertion failed.

3   Fail
s = 'The answer is 42'; b = [4 7 3]; y_correct = {'The ','answer ','is '}; assert(isequal(break_string(s,b),y_correct))

c = 3×1 cell array {0×0 double} {0×0 double} {0×0 double} c = 3×1 cell array {'The ' } {0×0 double} {0×0 double} n = 5 c = 3×1 cell array {'The ' } {'ans' } {0×0 double} n = 12 c = 3×1 cell array {'The ' } {'ans' } {1×0 char} n = 15

Assertion failed.

4   Fail
s = 'Did I do that?'; b = [2 3 3]; y_correct = {'Di','d I',' do'}; assert(isequal(break_string(s,b),y_correct))

c = 3×1 cell array {0×0 double} {0×0 double} {0×0 double} c = 3×1 cell array {'Di' } {0×0 double} {0×0 double} n = 3 c = 3×1 cell array {'Di' } {'d' } {0×0 double} n = 6 c = 3×1 cell array {'Di' } {'d' } {1×0 char} n = 9

Assertion failed.

5   Fail
s = 'Yes no when?'; b = [2 6 3]; y_correct = {'Ye','s no w','hen'}; assert(isequal(break_string(s,b),y_correct))

c = 3×1 cell array {0×0 double} {0×0 double} {0×0 double} c = 3×1 cell array {'Ye' } {0×0 double} {0×0 double} n = 3 c = 3×1 cell array {'Ye' } {'s no' } {0×0 double} n = 9 c = 3×1 cell array {'Ye' } {'s no' } {1×0 char} n = 12

Assertion failed.

6   Fail
s = 'Hello there'; b = [3 4 4]; y_correct = {'Hel','lo t','here'}; assert(isequal(break_string(s,b),y_correct))

c = 3×1 cell array {0×0 double} {0×0 double} {0×0 double} c = 3×1 cell array {'Hel' } {0×0 double} {0×0 double} n = 4 c = 3×1 cell array {'Hel' } {'l' } {0×0 double} n = 8 c = 3×1 cell array {'Hel' } {'l' } {1×0 char} n = 12

Assertion failed.

7   Fail
s = 'One is not enough!'; b = [3 1 1]; y_correct = {'One',' ','i'}; assert(isequal(break_string(s,b),y_correct))

c = 3×1 cell array {0×0 double} {0×0 double} {0×0 double} c = 3×1 cell array {'One' } {0×0 double} {0×0 double} n = 4 c = 3×1 cell array {'One' } {1×0 char } {0×0 double} n = 5 c = 3×1 cell array {'One' } {1×0 char} {1×0 char} n = 6

Assertion failed.