# Magic squares

Hi!
I'm interested in generating a sort of magic square (or rather - magic cube), when all (or some) sums are known and also some numbers to put in are known.
E.g. create a square, where sums at each column are: 15,18,22,14,19 (from left to right), and numbers in square range from 3 to 8 (each number can appear more than once).

I'd be grateful for any help.

Thanks,
Sorrow.

• You would really have to know a little more than that to solve it. But here's how to generate the appropriate algorithm: think of how you would do it on your own.

In each square, assume that the value is approximately 1/4 of the sum, for a 4X4 square. Then, create the rest of the first colomn using that method. Now work across from the top row, but now each square takes 1/3 of the sum after you've subtracted what you already know. Then you work down again. When you find that you don't have enough numbers to play with, adjust 1 of the numbers set previously, and try again, until you reach the bottom right corner. If you did it right, then the sum of the diagonals should equal the number printed in the bottom corner.

Your most important program will require more memory and processing power than you have.