Cody

Problem 1286. MatCAT - Reconstruct X from Its X-rays

Solution 2921035

Submitted on 7 Sep 2020
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
row_sums = [3 5 11]; col_sums = [4 7 8]; x = matcat(row_sums,col_sums); assert(all(x(:)>=0)) assert(isequal(floor(x),x)) assert(isequal(sum(x,2)',row_sums)) assert(isequal(sum(x,1),col_sums))

x = 0.6316 1.1053 1.2632 1.0526 1.8421 2.1053 2.3158 4.0526 4.6316

Assertion failed.

2   Fail
row_sums = [2 2 2 2 2 6]; col_sums = [2 3 3 3 3 2]; x = matcat(row_sums,col_sums); assert(all(x(:)>=0)) assert(isequal(floor(x),x)) assert(isequal(sum(x,2)',row_sums)) assert(isequal(sum(x,1),col_sums))

x = 0.2500 0.3750 0.3750 0.3750 0.3750 0.2500 0.2500 0.3750 0.3750 0.3750 0.3750 0.2500 0.2500 0.3750 0.3750 0.3750 0.3750 0.2500 0.2500 0.3750 0.3750 0.3750 0.3750 0.2500 0.2500 0.3750 0.3750 0.3750 0.3750 0.2500 0.7500 1.1250 1.1250 1.1250 1.1250 0.7500

Assertion failed.

3   Pass
row_sums = [65 65 65 65 65]; col_sums = [65 65 65 65 65]; x = matcat(row_sums,col_sums); assert(all(x(:)>=0)) assert(isequal(floor(x),x)) assert(isequal(sum(x,2)',row_sums)) assert(isequal(sum(x,1),col_sums))

x = 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13

4   Fail
row_sums = [22 34 33]; col_sums = [15 23 18 21 12]; x = matcat(row_sums,col_sums); assert(all(x(:)>=0)) assert(isequal(floor(x),x)) assert(isequal(sum(x,2)',row_sums)) assert(isequal(sum(x,1),col_sums))

x = 3.7079 5.6854 4.4494 5.1910 2.9663 5.7303 8.7865 6.8764 8.0225 4.5843 5.5618 8.5281 6.6742 7.7865 4.4494

Assertion failed.

5   Pass
row_sums = 55; col_sums = [1 2 3 4 5 6 7 8 9 10]; x = matcat(row_sums,col_sums); assert(all(x(:)>=0)) assert(isequal(floor(x),x)) assert(isequal(sum(x,2)',row_sums)) assert(isequal(sum(x,1),col_sums))

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

Suggested Problems

More from this Author50

Community Treasure Hunt

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

Start Hunting!