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
-
Make an awesome ramp for a tiny motorcycle stuntman
692 Solvers
-
Return the first and last characters of a character array
10882 Solvers
-
185 Solvers
-
1009 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
2014 Solvers
More from this Author299
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!