diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-05-28 10:29:13 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-05-28 10:29:13 +0200 |
commit | f05d888a0b621ca4e99e2b0fb6e23c097006fe41 (patch) | |
tree | eebbb2489144112d3288393e354d19375a0aa088 /progs/a492.py |
Init
Diffstat (limited to 'progs/a492.py')
-rw-r--r-- | progs/a492.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/progs/a492.py b/progs/a492.py new file mode 100644 index 0000000..3e1b9c3 --- /dev/null +++ b/progs/a492.py @@ -0,0 +1,17 @@ +def magic_square_test(my_matrix):
+ iSize = len(my_matrix[0])
+ sum_list = []
+ sum_list.extend([sum (lines) for lines in my_matrix])
+ for col in range(iSize):
+ sum_list.append(sum(row[col] for row in my_matrix))
+ result1 = 0
+ for i in range(0,iSize):
+ result1 +=my_matrix[i][i]
+ sum_list.append(result1)
+ result2 = 0
+ for i in range(iSize-1,-1,-1):
+ result2 +=my_matrix[i][i]
+ sum_list.append(result2)
+ if len(set(sum_list))>1:
+ return False
+ return True
\ No newline at end of file |