A magic square is an NxN grid where all columns, rows, and diagonals add to the same number. In the case of diagonals on top corner to opposite bottom corner count. Can you create a function that takes in an NxN array and returns if that array is a magic square or not? An example of a 3x3 magic square is below:
4 9 2 3 5 7 8 1 6
Comments:
Jared DiCioccio - 9 years, 7 months ago
Quick and dirty python
reply permalink
Max Burstein - 9 years, 7 months ago
Nicely done!
reply permalink