The Challenger puzzle by Linus Maurer requires the solver to fill a 4x4 matrix of integers from 1 to 9 to match the given sums of the rows, columns, main diagonal, and anti-diagonal. Four of the numbers are given. Numbers can be repeated, and the solution is not necessarily unique.
Write a function to solve the Challenger. The input will be a matrix resembling the game board. For example, if the input is
NaN NaN NaN NaN 12
0 0 0 4 23
0 1 0 0 11
6 0 0 0 21
0 0 2 0 13
9 20 22 17 12
then the sums of the four columns are 9, 20, 22, and 17. The sums of the rows are 23, 11, 21, and 13, and the sums of the two diagonals are 12 and 12. The four starting numbers are 6, 1, 2, and 4, and zeros indicate the numbers to be determined. Ignore the NaNs. The output of the function should be the 4x4 matrix of numbers. In the example, a valid solution would be
1 9 9 4
1 1 4 5
6 3 7 5
1 7 2 3
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers27
Suggested Problems
-
Project Euler: Problem 7, Nth prime
1748 Solvers
-
1711 Solvers
-
1181 Solvers
-
How many trades represent all the profit?
615 Solvers
-
1226 Solvers
More from this Author321
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
can the 4 given numbers be any of the 16?
In the four tests, there is one given number in each row and column.