Problem 1286. MatCAT - Reconstruct X from Its X-rays
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.
Solution Stats
Problem Comments
-
4 Comments
Nice problem
good problem.
See also this: https://it.mathworks.com/matlabcentral/cody/problems/47618
There is a nice video explaining how to solve these problems.
Solution Comments
Show commentsGroup

Project Euler II
- 12 Problems
- 51 Finishers
- Find the longest sequence of 1's in a binary sequence.
- Convert given decimal number to binary number.
- Find out sum and carry of Binary adder
- Binary numbers
- Given an unsigned integer x, find the largest y by rearranging the bits in x
- Bit Reversal
- Relative ratio of "1" in binary number
- Binary code (array)
- Converting binary to decimals
- There are 10 types of people in the world
Problem Recent Solvers121
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!