+ 8

How to do this question??

Define the function is_magic_square(matrix) that will take in a list of lists. If the square is magic, return True, otherwise return False. A square is magic if each cell contains a different integerand the sum of the integers in each row, column and diagonal is equal. matrix: an N by N list of lists. 1x1 e.g. [[1]] 3x3 e.g. [[4,9,2],[3,5,7],[8,1,6]] 4x4 e.g. [[7,12,1,14],[2,13,8,11],[16,3,10,5],[9,6,15,4]] For example,  is_magic_square([[1]]) should return True. is_magic_square([[1,2],[3,4]]) should re

13th Oct 2017, 10:32 AM
Damaen
Damaen - avatar
2 ответов
+ 4
thanks but I am in python.
13th Oct 2017, 12:30 PM
Damaen
Damaen - avatar
+ 3
If calculate like your sentense following would be like this (no checking for repeated number yet) https://code.sololearn.com/WLvqz4kHfkp0/?ref=app
13th Oct 2017, 12:27 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar