Cody

Solution 1463115

Submitted on 14 Mar 2018 by Emmanuel Afolabi
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))

m = 1 c = 1×1 cell array {[10]} m = 2 c = 1×1 cell array {1×2 double} m = 3 c = 1×1 cell array {1×3 double} m = 4 m = 1 c = 1×2 cell array {1×3 double} {[58]} m = 2 c = 1×2 cell array {1×3 double} {1×2 double} m = 3 m = 1 c = 1×3 cell array {1×3 double} {1×2 double} {[43]} m = 2 c = 1×3 cell array {1×3 double} {1×2 double} {1×2 double} m = 3 c = 1×3 cell array {1×3 double} {1×2 double} {1×3 double} m = 4 c = 1×3 cell array {1×3 double} {1×2 double} {1×4 double} m = 5

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

m = 1 c = 1×1 cell array {[1]} m = 2 m = 1 c = 1×2 cell array {[1]} {[2]} m = 2 m = 1 c = 1×3 cell array {[1]} {[2]} {[3]} m = 2 m = 1 c = 1×4 cell array {[1]} {[2]} {[3]} {[4]} m = 2 m = 1 c = 1×5 cell array {[1]} {[2]} {[3]} {[4]} {[5]} m = 2

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'} m = 1 c = 1×1 cell array {'H'} m = 2 c = 1×1 cell array {'He'} m = 3 c = 1×1 cell array {'Hel'} m = 4 c = 1×1 cell array {'Hell'} m = 5 c = 1×1 cell array {'Hello'} m = 6 m = 1 c = 1×2 cell array {'Hello'} {' '} m = 2 m = 1 c = 1×3 cell array {'Hello'} {' '} {'w'} m = 2 c = 1×3 cell array {'Hello'} {' '} {'wo'} m = 3 c = 1×3 cell array {'Hello'} {' '} {'wor'} m = 4 c = 1×3 cell array {'Hello'} {' '} {'worl'} m = 5 c = 1×3 cell array {'Hello'} {' '} {'world'} m = 6