From: hoaluong@swordfish.berkeley.edu (Howard Cam Luong)
Newsgroups: soc.culture.vietnamese
Subject: Re: [Help]..Math expert needed...
Date: 11 Sep 92 07:53:09 GMT
Reply-To: hoaluong@swordfish.Berkeley.EDU


In article <1992Sep8.163631.1@ttd.teradyne.com> nguyen@ttd.teradyne.com writes:
>Hi pals,
>
>My little nephew asked me to solve a puzzle which I can't come up with an
>answer for.  Maybe some MATH experts out there may help me explain the
>solution to a puzzled nephew of an incompetent uncle like moi :-)).
>
>      The Problem :
>
>              Given a 5x5 square, and a set of numbers I such that
>
>                       1 <= I <= 25
>
>              Fill the 5x5 square such that the sum of each row is equal
>              to 65.  And the sum of each column is also equal to 65.  As
>              well as the sum of each diagonal equals to 65.
>
>              Note: each number between 1 and 25 can only be used once.
>
>      Can you find a formular for this problem.  If it were a 4x4 or a 6x6
>      square, would the formular hold true?
>
>I've tried to generate a set of permutations on my P.C that fit the bill, but
>this method is just a "black box solution" which I don't really care for.
>
>Cheers,
>.."Pray 4-HiWind"
>

The following is a simple and easy-to-remember way you can solve 
the problem for an NxN square where N is an odd number.

1. Extend the rows and columns to get a diamond-like object

	N = 3:
	                   +++++
	                   :   :   
	               -------------
	               |   |   |   |   	
                   ++++-------------++++
                   :   |   |   |   |   :	
                   ++++-------------++++
	               |   |   |   |   	
	               -------------
 	                   :   :   
	                   +++++


	N = 5:
      		           +++++	
	                   :   :  
	               +++++++++++++
	               :   :   :   : 
	           ---------------------
	           |   |   |   |   |   |  	   	
               ++++---------------------++++
	       :   |   |   |   |   |   |   : 	   	
           ++++++++---------------------++++++++
	   :   :   |   |   |   |   |   |   :   :	   	
           ++++++++---------------------++++++++
	       :   |   |   |   |   |   |   : 	   	
               ++++---------------------++++
	           |   |   |   |   |   |  	   	
           	   ---------------------
	               :   :   :   : 
	               +++++++++++++
	                   :   :  
		           +++++	

2. Fill in all the diagonals that have N entries starting from 1 to (N*N) 

	N = 3:
	                   +++++
	                   : 9 :   
	               -------------
	               | 8 |   | 6 |   	
                   ++++-------------++++
                   : 7 |   | 5 |   | 3 :	
                   ++++-------------++++
	               | 4 |   | 2 |   	
	               -------------
 	                   : 1 :   
	                   +++++


	N = 5:
      		           +++++	
	                   :25 :  
	               +++++++++++++
	               :24 :   :20 : 
	           ---------------------
	           |23 |   |19 |   |15 |  	   	
               ++++---------------------++++
	       :22 |   |18 |   |14 |   |10 : 	   	
           ++++++++---------------------++++++++
	   :21 :   |17 |   |13 |   | 9 |   : 5 :	   	
           ++++++++---------------------++++++++
	       :16 |   |12 |   | 8 |   | 4 : 	   	
               ++++---------------------++++
	           |11 |   | 7 |   | 3 |  	   	
           	   ---------------------
	               : 6 :   : 2 : 
	               +++++++++++++
	                   : 1 :  
		           +++++	


3. Finally, fill up the empty spaces in the original NxN square by moving
all the numbers outside the square N spaces to the left, right, up, or down 
according to their positions (there is only one way to move each of these 
numbers inside!).  There is the solution.


	N = 3:
	                     +++++
	                     : 9 :   

	                 -------------
	                 | 8 | 1 | 6 |   	
                   ++++  -------------  ++++
                   : 7   | 3 | 5 | 7 |   3 :	
                   ++++  -------------  ++++
	                 | 4 | 9 | 2 |   	
	                 -------------

 	                     : 1 :   
	                     +++++


	N = 5:
      		             +++++	
	                     :25 :  
	                 +++++++++++++
	                 :24 :   :20 : 

	             ---------------------
	             |23 | 6 |19 | 2 |15 |  	   	
               ++++  ---------------------  ++++
	       :22   |10 |18 | 1 |14 |22 |  10 : 	   	
           ++++++++  ---------------------  ++++++++
	   :21 :     |17 | 5 |13 |21 | 9 |     : 5 :	   	
           ++++++++  ---------------------  ++++++++
	       :16   | 4 |12 |25 | 8 |16 |   4 : 	   	
               ++++  ---------------------  ++++
	             |11 |24 | 7 |20 | 3 |  	   	
           	     ---------------------

	                 : 6 :   : 2 : 
	                 +++++++++++++
	                     : 1 :  
		             +++++	


I strongly believe that you can generalize the solution for any odd 
number N.

Have fun.

Hoa.
Newsgroups: soc.culture.vietnamese