English version is in beta. All contents of the site should be already translated (mostly using machine translation), and everything should work properly. However, if you find any problems, please contact me.
The problem statement has been automatically translated from Russian. If the statement is not clear, or you have any comments about it, please contact me. Anyway, I hope that someday I will fix the translation manually.
Magic Square
We will call a magic square a square with the same sum of numbers on all verticals and horizontals; we will not impose any requirements on sums on diagonals. Make such a square from a given set of numbers.
Input data
The input file contains 16 different integers in the range from 0 to 32768
Output data
In the output file, you need to output the desired location of the numbers that make up the magic square 4 * 4 (each number must occur exactly once), in four lines of four numbers, or the line NO SOLUTION, if the square cannot be made.
Examples
Input data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Output data
1 6 13 14 2 11 12 9 15 7 4 8 16 10 5 3
algoprog.ru © Petr Kalinin, GNU AGPL, github.com/petr-kalinin/algoprog | About the license for the site materials | Blog (in Russian)