Cody

Problem 7. Column Removal

Solution 1388077

Submitted on 20 Dec 2017 by Bailey Horton
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
A = [1 2 3; 4 5 6]; n = 2; B_correct = [1 3; 4 6]; assert(isequal(column_removal(A,n),B_correct))

rows = 2 columns = 3 BLeft = 0 0 BLeft = 1 0 BLeft = 1 4 BRight = 0 0 BRight = 3 0 BRight = 3 6 B = 1 3 4 6

2   Pass
A = magic(4); n = 3; B = [16 2 13; 5 11 8; 9 7 12; 4 14 1]; B_correct = B; assert(isequal(column_removal(A,n),B_correct))

rows = 4 columns = 4 BLeft = 0 0 0 0 0 0 0 0 BLeft = 16 0 0 0 0 0 0 0 BLeft = 16 0 5 0 0 0 0 0 BLeft = 16 0 5 0 9 0 0 0 BLeft = 16 0 5 0 9 0 4 0 BLeft = 16 2 5 0 9 0 4 0 BLeft = 16 2 5 11 9 0 4 0 BLeft = 16 2 5 11 9 7 4 0 BLeft = 16 2 5 11 9 7 4 14 BRight = 0 0 0 0 BRight = 13 0 0 0 BRight = 13 8 0 0 BRight = 13 8 12 0 BRight = 13 8 12 1 B = 16 2 13 5 11 8 9 7 12 4 14 1

3   Pass
A = 1:10; n = 7; B_correct = [1 2 3 4 5 6 8 9 10]; assert(isequal(column_removal(A,n),B_correct))

rows = 1 columns = 10 BLeft = 0 0 0 0 0 0 BLeft = 1 0 0 0 0 0 BLeft = 1 2 0 0 0 0 BLeft = 1 2 3 0 0 0 BLeft = 1 2 3 4 0 0 BLeft = 1 2 3 4 5 0 BLeft = 1 2 3 4 5 6 BRight = 0 0 0 BRight = 8 0 0 BRight = 8 9 0 BRight = 8 9 10 B = 1 2 3 4 5 6 8 9 10

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!