Magic Square and Sudoku
Time limit1sMemory limit512 MB
Construct a 16 by 16 Sudoku in which every 4 by 4 box is a magic square, and print any valid grid.
- Level
Medium6 of 10
- Topics
- Math, Implementation, Matrix
- Solved
- No attempts yet
Problem
Jisu became friends with Joshua Müller, a passionate math puzzle fan, while studying in Germany. Joshua especially likes magic squares (Zauberquadrat) and Sudoku. According to Joshua, people think Sudoku is fun to solve at any time, but magic squares are rarely solved because their easy solving method is well known.
A magic square is defined as follows.
The board of a magic square is an grid. Each cell must contain exactly one integer from to . The sum of the numbers in each of the rows, each of the columns, and the 2 diagonals must all be equal.
A Sudoku is defined as follows.
The board of a Sudoku is an grid, divided into smaller boards of size . Each cell can contain an integer from to . In each of the rows, columns, and smaller boards, each integer from to must appear exactly once.
Joshua wants to combine magic squares with Sudoku. He tries to build an Sudoku in which each of the smaller boards is a magic square. Joshua found quickly that such a puzzle is impossible when . Soon after, he easily built a () puzzle that meets his conditions.
Joshua asks Jisu to build a puzzle that meets his conditions. Jisu is busy with an internship at a lab, so you will build the puzzle instead.
Input
This problem has no input.
Output
Print the constructed puzzle over 16 lines. If there are several answers, print any one of them.