[net.math] Magic Squares

eliovson@aecom.UUCP (05/02/84)

On 5/1 I was introduced to a technique for developing
the magic square, where all columns, any direction (including diagnols)
add up to the same sum- for example:

	      _________________________________________________________
 generation   :             O       3       3       3                  |
   of a       :  OOO       OOO     2OO     2 6     2 6     276     276 |
   3 X 3      :  OOO      OOOOO   1OOOO   1 5OO   1 5 9   1 5 9    951 |
 magic        :  OOO       OOO     OOO     4OO     4 8     438     438 |
     square   :             O       O       O       7                  |
	      ----------------------------------------------------------

When I sat down to write a program for the following I ran into
a small problem- does this only work with ODD squares? ie-

	1  2  3  4            4
	5  6  7  8          3   8
	9 10 11 12        2   7  12
       13 14 15 16      1   6  11  16
			  5  10  15
			    9  14
			     13

	  1st               2nd

leaves me blind-

So all you puzzlers out there- a formula or subroutine
would be much appreciated, and as our system doesn't
give access to net.sources any answers should be directly
mailed to me.

	Thanks alot,           "Today is the Tommorrow
	moshe eliovson          you worried about
				yesterday."

{spike|rocky2|philabs|pegasus|esquire|cucard}!aecom!eliovson

merlyn@sequent.UUCP (05/04/84)

> From: eliovson@aecom.UUCP
> Message-ID: <551@aecom.UUCP>
> Date: Tue, 1-May-84 19:30:38 PDT
> 
> On 5/1 I was introduced to a technique for developing
> the magic square...
> ...When I sat down to write a program for the following I ran into
> a small problem- does this only work with ODD squares?

Yes, only ODD squares are possible with this method.  It appears to be
isomorphic with a method I learned long ago:

1. Starting at the middle square of the top row, label that square "1".
2. For each successive number, go up one and right one square, wrapping right
   side to left and top to bottom as necessary.
3. If the square in step 2 is already taken, backup and go DOWN one instead
   (from the original square, not the up-right one).
4. Fill in that square with the next higher number, and repeat.

This one automatically generates any ODD-sized magic square.

Evidently, even ones are harder to generate.  I haven't seen an algorithm for
them yet.  I have a few special case ones, but that's about it.

Randal L. ("Entertainment = MagiC^2") Schwartz, esq. (merlyn@sequent.UUCP)
	(Official legendary sorcerer of the 1984 Summer Olympics)
Sequent Computer Systems, Inc. (503)626-5700 (sequent = 1/quosine)
UUCP: ...!XXX!sequent!merlyn where XXX is one of:
	decwrl nsc ogcvax pur-ee rocks34 shell teneron unisoft vax135 verdix
Original Material (C) 1984 by Randal L. Schwartz [ALL RIGHTS RESERVED]

colonel@gloria.UUCP (05/05/84)

[Find the flaw in this proof: ""]

There is no "easy" way to make an even magic square.  See
any standard reference on puzzles.
-- 
Col. G. L. Sicherman
...seismo!rochester!rocksvax!sunybcs!gloria!colonel