Suppose ms a two-dimensional square indexed from O to n 1 in both dimensions

education

Description

Suppose ms a two-dimensional square indexed from O to n — 1 in both dimensions. For an odd number n, a Simple algorithm for constructing magic squares exists: the square is constructed by filling in the numbers me To n2 in a run, starting at; = (n— 1)/2 and = n—1 and incrementing and by one in each step, modulo n. Every n-the step j is decremented by one and we left unchanged. In the square to the right, we start at, = 1 And j = 2 and put 1 in that Iodation incrementing ¡ makes ¡ 2 and incrementing j makes j = 3, where we Need to put2 (grey above), but modulo 3 makes j = 0 we find the location of 3 similarly but then need to Move one down and continue there with 4, etc., went a function magic square (n) that returns a square as A list of lists (but the function itself does not print it) and a function print square (s) that takes a list of lists And prints the square such that the numbers are aligned and there are two spaces between the numbers.


Related Questions in education category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.