Newsgroups: comp.lang.prolog,comp.constraints,sci.op-research
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!math.ohio-state.edu!uwm.edu!lll-winken.llnl.gov!enews.sgi.com!wdl1!dst17!mab
From: mab@dst17.wdl.loral.com (Mark A Biggar)
Subject: Re: Solving Magic Squares
Message-ID: <1995Jan12.225445.24109@wdl.loral.com>
Sender: news@wdl.loral.com
Organization: Loral Western Development Labs
References: <3etu2n$cag@gaudi.ac.upc.es> <DBP.95Jan11151327@proof.csli.stanford.edu> <3f3lg7$sic@barney.cs.city.ac.uk>
Date: Thu, 12 Jan 1995 22:54:45 GMT
Lines: 35
Xref: glinda.oz.cs.cmu.edu comp.lang.prolog:12101 comp.constraints:447 sci.op-research:2524

In article <3f3lg7$sic@barney.cs.city.ac.uk> jampel@cs.city.ac.uk (Michael Jampel) writes:
>David Barker-Plummer <dbp@csli.stanford.edu> wrote:
>>Offerred without proof: for odd-sided squares, place 1 in the middle
>>of the bottom row, and for each n+1 place it in the square at a
>>position two squares above and one to the right of n, wrapping round
>>the square where necessary.  If you obtain a collision, i.e. the
>>previous algorithm requires you to use a previously filled square,
>>then place n+1 in the square above n.
>>So,
>> ***       **2     **2     4*2     4*2     4*2     4*2     4*2     492
>> ***  ===> *** ==> 3** ==> 3** ==> 35* ==> 35* ==> 357 ==> 357 ==> 357 
>> *1*       *1*     *1*     *1*     *1*     *16     *16     816     816
>>                    collision               collision
>For n=5, do not place it two above and one to the right, but 4 above
>and one to the right. In general, perhaps, for a square of n, place it
>n-1 above and 1 to the right. If there is a collision, again put m+1'th
>number directly above m.
>Also appears to work for n=7 with a step of 6 up, one to the right.
>Why does this work?

Simpler method: start in middle of top row, place next number 1 place
diagonaly up to right (or left, you just get mirror image), on collision place
next number 1 place below last one.  This gives the sequence:

 *1*       *1*     *1*     *1*     *1*     *16     *16     816     816 
 ***  ===> *** ==> 3** ==> 3** ==> 35* ==> 35* ==> 357 ==> 357 ==> 357
 ***       **2     **2     4*2     4*2     4*2     4*2     4*2     492 

Same method work for any odd square.

--
Mark Biggar
mab@wdl.loral.com

 
