You are required to make a magic square, also known as Sudoku, with matrices of different sizes: 3x3, 4x4 and 5x5. In this box, you will have the option to choose only three positions to place numbers. Then, you must determine if it meets the condition to be considered a magic painting. In case it does not comply, you will be given the option to request the correct answer.
def magic_square(n, magic_constant): magicSquare=[] for i in range (n): l=[] for j in range (n): l.append(0) magicSquare.append(l) i=n//2 j=n-1 num=n*n count=num while (count!=0): if (i==-1 and j==n): j=n-2 i=0 else: if (j==n): j=0 if (i<0): i=n-1 if (magicSquare[i][j]!=0): j=j-2 i=i+1 continue else: magicSquare[i][j]=num num=num-1 count=count-1 i=i-1 j=j+1 for i in range (n): for j in range (n): print