LearnPy Hub
← Comprehensions problems
Hard

Is It a Magic Square?

Read n and an n × n grid. It is a magic square if it contains each number 1..n² once and every row, column and both diagonals add up to the same total. Compute all the sums with comprehensions and print magic TOTAL or not magic.

Input

n, then n rows.

Output

One line.

Sample 1

Input
3
2 7 6
9 5 1
4 3 8
Output
magic 15

Sample 2

Input
3
1 2 3
4 5 6
7 8 9
Output
not magic
solution.py
Output appears here
Is It a Magic Square? · Python practice problem · LearnPy Hub