Cody

# Problem 2953. Split array into pieces according to corresponding array

Solution 1702685

Submitted on 4 Jan 2019 by Anna Di Gialleonardo
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=[ 1 1 1 2 2 3 3 3 3]; y=[10 52 12 58 21 43 89 27 98]; c={[10 52 12],[58 21],[43 89 27 98]}; assert(isequal(split_array(x,y),c))

a = 1 c = 1×3 cell array {1×3 double} {0×0 double} {0×0 double} c = 1×3 cell array {1×3 double} {1×2 double} {0×0 double} c = 1×3 cell array {1×3 double} {1×2 double} {1×4 double}

2   Pass
x=1:5; c=num2cell(1:5); assert(isequal(split_array(x,x),c));

a = 1 c = 1×5 cell array {[1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} c = 1×5 cell array {[1]} {[2]} {0×0 double} {0×0 double} {0×0 double} c = 1×5 cell array {[1]} {[2]} {[3]} {0×0 double} {0×0 double} c = 1×5 cell array {[1]} {[2]} {[3]} {[4]} {0×0 double} c = 1×5 cell array {[1]} {[2]} {[3]} {[4]} {[5]}

3   Pass
x=[1 1 1 1 1 2 3 3 3 3 3]; y='Hello world'; c={'Hello' ' ' 'world'} assert(isequal(split_array(x,y),c));

c = 1×3 cell array {'Hello'} {' '} {'world'} a = 1 c = 1×3 cell array {'Hello'} {0×0 double} {0×0 double} c = 1×3 cell array {'Hello'} {' '} {0×0 double} c = 1×3 cell array {'Hello'} {' '} {'world'}