Back
Close
  • 104

Statement

 Goal

A magic square is a n×n square grid (where n is the number of cells on each side) filled with distinct positive integers in the range 1, 2 …, such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal. The sum is called the magic constant or magic sum of the magic square. Print MAGIC if the given square is magic or else MUGGLE.
Input
Line 1 : n
n lines : A line of the square
Output
Line 1 : MAGIC or MUGGLE
Example
Input
3
2 7 6
9 5 1
4 3 8
Output
MAGIC
Solve it

A higher resolution is required to access the IDE

codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants