Cody

Problem 2404. Reshape a Vector

Solution 1972628

Submitted on 12 Oct 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
n=2; m=5; S=1:10; y_correct =[1 2 3 4 5 6 7 8 9 10]; assert(isequal(ResHape(S,m,n),y_correct))

y = 1 6 2 7 3 8 4 9 5 10 y = 1 2 2 7 3 8 4 9 5 10 y = 1 2 1 2 3 8 4 9 5 10 y = 1 2 1 2 1 2 4 9 5 10 y = 1 2 1 2 1 2 1 2 5 10 y = 1 2 1 2 1 2 1 2 1 2

Assertion failed.

2   Fail
n=4; m=8; S=[1:10 6:12 5:19] y_correct=[ 1 2 3 4 5 6 7 8 9 10 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19] assert(isequal(ResHape(S,m,n),y_correct))

S = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 31 through 32 18 19 y_correct = 1 2 3 4 5 6 7 8 9 10 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 y = 1 9 12 12 2 10 5 13 3 6 6 14 4 7 7 15 5 8 8 16 6 9 9 17 7 10 10 18 8 11 11 19 y = 1 2 3 4 2 10 5 13 3 6 6 14 4 7 7 15 5 8 8 16 6 9 9 17 7 10 10 18 8 11 11 19 y = 1 2 3 4 1 2 3 4 3 6 6 14 4 7 7 15 5 8 8 16 6 9 9 17 7 10 10 18 8 11 11 19 y = 1 2 3 4 1 2 3 4 1 2 3 4 4 7 7 15 5 8 8 16 6 9 9 17 7 10 10 18 8 11 11 19 y = 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 5 8 8 16 6 9 9 17 7 10 10 18 8 11 11 19 y = 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 6 9 9 17 7 10 10 18 8 11 11 19 y = 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 7 10 10 18 8 11 11 19 y = 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 8 11 11 19 y = 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

Assertion failed.

3   Fail
n=2; m=31; S=[1:10 6:12 zeros(1,20) 5:19 ones(1,10)] y_correct=[1 2 3 4 5 6 7 8 9 10 6 7 8 9 10 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 1 1 1 1 1 1 1 1 1]; assert(isequal(ResHape(S,m,n),y_correct))

S = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 6 7 8 9 10 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 60 0 0 0 0 0 0 0 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 1 1 1 1 1 1 1 Columns 61 through 62 1 1 y = 1 0 2 0 3 0 4 0 5 0 6 0 7 5 8 6 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 2 0 3 0 4 0 5 0 6 0 7 5 8 6 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 3 0 4 0 5 0 6 0 7 5 8 6 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 4 0 5 0 6 0 7 5 8 6 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 5 0 6 0 7 5 8 6 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 6 0 7 5 8 6 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 7 5 8 6 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 8 6 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 9 7 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 10 8 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 9 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 7 10 8 11 9 12 10 13 11 14 12 15 0 16 0 17 0 18 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 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1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 0 19 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ...

Assertion failed.

Suggested Problems

More from this Author21

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!