MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Consider a matrix x

x = [ 1 2 0 0 5 0 3 0 8 ]

If we sum x along the rows we get

row_sums = [3 5 11]

Summing along the columns gives

col_sums = [4 7 8]

Metaphorically, we might call these sums "x-rays". Your job is to take these x-rays and reconstruct the matrix x being x-rayed, in the fashion of a CAT scan. Can you put all the bones in the right place?

All matrix elements must be non-negative integers. There is no guarantee of a unique answer. I will only check that the row and column sums match the supplied matrix, and that your elements are non-negative integers.

Bonus question: Under what circumstances does the answer become unique? Discuss.

23 correct solutions
6 incorrect solutions

Last solution submitted on Feb 16, 2015

1 Comment