View the step-by-step solution to:

Question

# In this assignment the programe will generate ALL magic squares of order 4 through permutation. The

process is straight forward but time consuming. Here are the steps:

1. Create a 1-D list of integers 1 through 16.
2. Permute this list of integers.
3. For each permutation convert the 1-D list into a 2-D list that is 4 x 4.
4. Check if that 2-D list is a magic square. If it is, then print it out.
5. Stop when you have gone through all the permutations.

The magic constant is given by n * (n2 + 1) / 2, where n is the dimension of the magic square. For a 4 x 4 magic square the constant is 34.

In this program there is no user input. You may reuse any code that you have written for the first assignment. To save space you may print out your magic squares as 1-D list of numbers. Your output will look as follows:

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents