Matrices and grids · 15 / 15 Exercise Medium

Magic square

Objective

A magic square is a square matrix in which all rows, all columns and both diagonals add up to the same value.

Instructions

  • The first line has the size n; then come n rows with n integers.
  • Show Magic or Not magic.
Input
3
2 7 6
9 5 1
4 3 8
Output
Magic

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise