Problem 46120. Solve the Challenger puzzle
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
Alex Sutherland
on 17 Feb 2023
can the 4 given numbers be any of the 16?
ChrisR
on 7 Mar 2023
In the four tests, there is one given number in each row and column.
Solution Comments
Show commentsProblem Recent Solvers15
Suggested Problems
-
Find the peak 3n+1 sequence value
2498 Solvers
-
1596 Solvers
-
374 Solvers
-
Convert Two Character String into a Binary Vector
202 Solvers
-
96 Solvers
More from this Author279
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!