Cody

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

Solution 1607982

Submitted on 13 Aug 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   Fail
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))

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

Assertion failed.

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

ans = 1×2 cell array {0×0 cell} {[1]} ans = 1×2 cell array {1×2 cell} {[2]} ans = 1×2 cell array {1×2 cell} {[3]} ans = 1×2 cell array {1×2 cell} {[4]} ans = 1×2 cell array {1×2 cell} {[5]}

Assertion failed.

3   Fail
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'} ans = 1×2 cell array {0×0 cell} {'Hello'} ans = 1×2 cell array {1×2 cell} {' '} ans = 1×2 cell array {1×2 cell} {'world'} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char} ans = 1×2 cell array {1×2 cell} {1×0 char}

Assertion failed.