From: phil kenny Newsgroups: sci.math Subject: Re: Magic square Date: Sun, 25 Jan 1998 12:10:19 -0800 Baptiste Heyman wrote: > > Does anyone know if there is a 6x6 magic square ? > > -------------------==== Posted via Deja News ====----------------------- > http://www.dejanews.com/ Search, Read, Post to Usenet Here is a 6x6 magic square with an unusual property. If you strip off the outer border of cells, a 4x4 magic square remains. 1 35 30 5 34 6 33 11 24 25 14 4 28 18 21 20 15 9 10 22 17 16 19 27 8 23 12 13 26 29 31 2 7 32 3 36 This appeared in a Dover publication: "Magic Squares and Cubes" by W. S. Andrews, 1960. Sorry, no ISBN. Several other examples of 'concentric' magic squares also are listed in this reference. Regards, phil kenny ============================================================================== From: Baptiste Heyman Newsgroups: sci.math Subject: Re: Magic Squares Date: Sat, 28 Mar 1998 21:36:39 +0100 Anton Ivanov wrote: > > I am working on an age-old problem: magic squares. I have found the > procedure for the 3x3 squares, but I can't seem to find one for 5x5 and > so on. Does anyone know of one? 5 4 10 !---!---!---!---!---! ! 3 ! ! 9 ! !15 ! !---!---!---!---!---! 2 ! ! 8 ! !14 ! !20 !---!---!---!---!---! 1 ! 7 ! !13 ! !19 ! 25 !---!---!---!---!---! 6 ! !12 ! !18 ! !24 !---!---!---!---!---! !11 ! !17 ! !23 ! !---!---!---!---!---! 16 22 21 !---!---!---!---!---! ! 3 !16 ! 9 !22 !15 ! !---!---!---!---!---! !20 ! 8 !21 !14 ! 2 ! !---!---!---!---!---! ! 7 !25 !13 ! 1 !19 ! !---!---!---!---!---! !24 !12 ! 5 !18 ! 6 ! !---!---!---!---!---! !11 ! 4 !17 !10 !23 ! !---!---!---!---!---! ============================================================================== From: jasonp@Glue.umd.edu (Jason Stratos Papadopoulos) Newsgroups: sci.math Subject: Re: Magic square Date: 26 Jan 1998 08:13:47 GMT GSimp95605 (gsimp95605@aol.com) wrote: : isn't there an algorithm for "all" nxn magic squares where n>2 and the : individual squares are filled with the numbers 1,2,3,... n^2? : I know it for odd n, and about a month ago I saw one for even n. This was posted here a long time ago. Note also that the International Obfuscated C Code Contest had a magic square generator win the "most obfuscated algorithm" award a while back. The program is pretty neat, but don't learn the algorithm from it! Anyway, the most general method I've seen is given in "Magic Squares and Cubes", but requires solving (what seems to me) a really complicated combinatorics problem. Rather than repeat myself, look in DejaNews for a post with "thorny combinatorics problem" in the title. jasonp PS: Many more magic squares of odd size are possible than what the poster mentioned; in particular you can start from anywhere in the square except the middle, but the rules change slightly depending on where you start. -------------------------------------------------------------------------- From: "Shin, Kwon Young" Newsgroups: sci.math Subject: Perfect Magic Square Solution Date: Tue, 01 Apr 1997 01:35:53 +0900 THE SOLUTION FOR "THE MAGIC SQUARE" =================================== Have you ever heard of the 'Magic Square'? It's a mathematical 'brain-twister' where the sum of the numbers of a row, column or diagonal in a square n*n is always equal. For example, look at
+---+---+---+ : 8 : 1 : 6 : +---+---+---+ The sum of each row, column, or : 3 : 5 : 7 : diagonal is 15. +---+---+---+ : 4 : 9 : 2 : +---+---+---+ n=3, sum=15 [Figure 1.] Some of you know the solution to the squares n*n where 'n' equals an odd-number(3,5,7,9,...). +---+---+---+---+ : 1 :15 :14 : 4 : But, in the case of an even-numbered +---+---+---+---+ series like in
, the solution :12 : 6 : 7 : 9 : is different. +---+---+---+---+ : 8 :10 :11 : 5 : So, I'll demonstrate the solutions for +---+---+---+---+ the 3 types of Magic Squares. :13 : 3 : 2 :16 : +---+---+---+---+ n=4, sum=34 [Figure 2.] 1. The Solution To The Odd-Series (n=3,5,7,9,...) -------------------------------------------------- (2) +---+---+---/---+---+ 1) Put the first number in the middle : : : 1 : : : column of the top row. +---+---+---+---+---+ : : 5 : : : : 2) Put the next number in the box moved +---/-v-+---+---+---+ one column to the right and one row up. : 4 : 6 : : : :(4) If the number exceeds a column or a row, /---+---+---+---+---/ place it in the opposite side of that : : : : : 3 : column or row. +---+---+---+---/---+ : : : : 2 : : 3) Repeat step-2 'n' times until you reach +---+---+---/---+---+ the original starting Position. [Figure 3-(a)] 4) Place the next number in the same +---+---+---+---+---+ column one row below the last number : : : 1 : 8 :15 : and continue with step-2. +---+---+---+---+---+ : : 5 : 7 :14 :16 : +---+---+---+---+---+ : 4 : 6 :13 : : : +---+---+---+---+---+ :10 :12 : : : 3 : +---+---+---+---+---+ :11 : : : 2 : 9 : +---+---+---+---+---+ [Figure 3-(b)] +---+---+---+---+---+ Basically, you're placing the number in :17 :24 : 1 : 8 :15 : consecutive order diagonally up and to the +---+---+---+---+---+ right until all spaces are filled. :23 : 5 : 7 :14 :16 : +---+---+---+---+---+ : 4 : 6 :13 :20 :22 : +---+---+---+---+---+ :10 :12 :19 :21 : 3 : +---+---+---+---+---+ n=5, :11 :18 :25 : 2 : 9 : sum=65 +---+---+---+---+---+ [Figure 3-(c)] 2. The Solution To The Multiple Of 4 (n=4,8,12,16,...) ------------------------------------------------------- k 2k k +---+---+---+---+ 1) Divide the square into 9 areas as | A |///B///| C | k shown left(
). +===+===+===+===+ |///| ' |///| 2) Write the numbers in their correspond- +/D/+- -E- -+/F/+2k ing boxes of areas A, C, E, G and I. |///| . |///| +===+===+===+===+ | G |///H///| I | k 3) Place the remaining numbers in reverse +---+---+---+---+ corresponding order from left to right [Figure 4.] starting from the bottom. ex)) n=8, sum=260 You can check the square +---+---*---+---+---+---*---+---+ 4*4(
) and : 1 : 2 |62 :61 :60 :59 | 7 : 8 : 8*8(
). +---+---*---+---+---+---*---+---+ : 9 :10 |54 :53 :52 :51 |15 :16 : It's very simple!! *===*===*===*===*===*===*===*===* :48 :47 |19 :20 :21 :22 |42 :41 : +---+---*---+---+---+---*---+---+ :40 :39 |27 :28 :29 :30 |34 :33 : +---+---*---+---+---+---*---+---+ :32 :31 |35 :36 :37 :38 |26 :25 : +---+---*---+---+---+---*---+---+ :24 :23 |43 :44 :45 :46 |18 :17 : *===*===*===*===*===*===*===*===* :49 :50 |14 :13 :12 :11 |55 :56 : +---+---*---+---+---+---*---+---+ :57 :58 | 6 : 5 : 4 : 3 |63 :64 : +---+---*---+---+---+---*---+---+ [Figure 5.] 2. The Solution To The Other Series (n=6,10,14,18,...) ------------------------------------------------------- 1) Divide the square into areas shown below. k 1 2k 1 k +-----*---*-----+-----*---*-----+ : A | | B | | C : k : | | | | : *=====*===*=====+=====*===*=====* up block : | % | | % | : 1 *=====*===*=====+=====*===*=====* : | | | | : : | | | | : + D + + E + + F +2k : | | | | : : | | | | : *=====*===*=====+=====*===*=====* down block: | % | | % | : 1 *=====*===*=====+=====*===*=====* : | | | | : : G | | H | | I : k +-----*---*-----+-----*---*-----+ left right block block [Figure 6.] 2) Applying the solution of "the multiple of 4s" to the areas marked A to I, fill in the boxes. ex)) n=6, sum=111 +---+---+---+---+---+---+ Place the corresponding numbers : 1 | |34 :33 | | 6 : (cf. 8, 11, 26, 29) in the boxes +===+===+===+===+===+===+ marked '%'. : | 8 | : |11 | : +===+===+===+===+===+===+ :24 | |15 :16 | |19 : +---+---+---+---+---+---+ :18 | |21 :22 | |13 : +===+===+===+===+===+===+ : |26 | : |29 | : +===+===+===+===+===+===+ :31 | | 4 : 3 | |36 : +---+---+---+---+---+---+ [Figure 7.] 3) Fill in the numbers into corresponding boxes in the 4 'blocks'. However, be aware of 2 things; a) the numbers in the blocks are temporary as they will be switched around later. b) the numbers in the areas marked '%' are permanent, therefore, not to be touched. - -+---+ - - - +---+- - : | 2 | | 5 | : +---+---+---+---+---+---+ | 7 | % | 9 |10 | % |12 | +---+---+---+---+---+---+ : |14 | |17 | : : +---+ +---+ : : |20 | |23 | : +---+---+---+---+---+---+ |25 | % |27 |28 | % |30 | +---+---+---+---+---+---+ : |32 | |35 | : - -+---+ - - --+---+- - [Figure 8.] 4) Take the left and right blocks. 2 5 2 35 2 35 2 35 -- -- -- -- -- -- -- -- 14 17 ===> 14 23 ===> 23 14 ===> 23 14 20 23 (a) 20 17 (b) 17 20 (c) 20 17 -- -- -- -- -- -- -- -- 32 35 32 5 32 5 32 5 [Figure 9.] (a) Place the right block numbers in reverse order. (b) Switch the numbers in the middle rows between the left and right blocks. (c) Take the number directly below the center line re-switch them. Now the left and right blocks are completed successfully. 5) Take the up and down blocks. 7: 9 10:12 12:10 9: 7 12:28 27: 7 30:28 27: 7 =>(a) =>(b) =>(c) 25:27 28:30 30:28 27:25 30:10 9:25 12:10 9:25 [Figure 10.] (a) Place the numbers of both blocks in reverse order. (It cause each sum of the column to unequal. But, You must switch all. If you switch only one side, you can't find out the numbers to re-switch at step (c). Therefore, some numbers in areas A - I have to be switched. This problem will be solved at step 6).) (b) Switch the numbers in the middle columns between the up and down blocks. (c) Switch the first numbers between the two blocks. 6) You must do a few more step to make the magic square complete. +---+===#*******#===+---+ : 1 | 2 #34 :33 #35 | 6 : +===*===#*******#===*===+ Choose one row from areas 'B' or 'H' |30 | 8 |28 :27 |11 | 7 : and, place those numbers in reverse +===*===*===+===*===*===+ order. (cf. 34 <--> 33) :24 |23 |15 :16 |14 |19 : #***#---+---+---+---#***# Choose one row from area 'D' and take #18 |20 |21 :22 |17 |13 # the corresponding row in area 'F'. #***#===*===+===*===#***# And place the number(s) in reverse |12 |26 |10 : 9 :29 |25 | order. (cf. 18 <--> 13) +===*===*===+===*===*===+ :31 |32 | 4 : 3 | 5 |36 : +---+===+---+---+===+---+ [Figure 11.] +---+---+---+---+---+---+ : 1 : 2 :33 :34 :35 : 6 : Abracadabra! The Magic Square!! +---+---+---+---+---+---+ :30 : 8 :28 :27 :11 : 7 : +---+---+---+---+---+---+ :24 :23 :15 :16 :14 :19 : +---+---+---+---+---+---+ :13 :20 :21 :22 :17 :18 : +---+---+---+---+---+---+ :12 :26 :10 : 9 :29 :25 : +---+---+---+---+---+---+ :31 :32 : 4 : 3 : 5 :36 : +---+---+---+---+---+---+ [Figure 12.] You can check the square 10*10. ex)) n=10, sum=505 +---+---+---+---+---+---+---+---+---+---+ : 1 : 2 : 3 :94 :95 :96 :97 :98 : 9 :10 : +---+---+---+---+---+---+---+---+---+---+ :11 :12 :13 :87 :86 :85 :84 :88 :19 :20 : +---+---+---+---+---+---+---+---+---+---+ :80 :29 :23 :77 :76 :75 :74 :28 :22 :21 : +---+---+---+---+---+---+---+---+---+---+ :70 :69 :68 :34 :35 :36 :37 :33 :62 :61 : +---+---+---+---+---+---+---+---+---+---+ :60 :59 :58 :44 :45 :46 :47 :43 :52 :51 : +---+---+---+---+---+---+---+---+---+---+ :41 :42 :53 :54 :55 :56 :57 :48 :49 :50 : +---+---+---+---+---+---+---+---+---+---+ :40 :39 :38 :64 :65 :66 :67 :63 :32 :31 : +---+---+---+---+---+---+---+---+---+---+ :30 :79 :73 :27 :26 :25 :24 :78 :72 :71 : +---+---+---+---+---+---+---+---+---+---+ :81 :82 :83 :17 :16 :15 :14 :18 :89 :90 : +---+---+---+---+---+---+---+---+---+---+ :91 :92 :93 : 7 : 6 : 5 : 4 : 8 :99 :100: +---+---+---+---+---+---+---+---+---+---+ [Figure 13.] Heeeeee-ww.. ;-) I greatly appreciate Jully Oh helps me to translate a Korean sentence into English. I Found this solution about 12 years ago. I don't know the solution have already been known or not. Anyway, I'm proud to find the solution to n=6,10,14,... series by myself. If you know the other solution, please let me know. I programmed the solution for the magic square with c-language. If you need the source, send me a mail please. Thank you.