# The Magic Hexagon

## Why not solve it the easy way!

The magic hexagon puzzle consists of arranging the numbers 1 to 19 in a hexagonal pattern (see below) in such a way that each row in any direction adds up to 38.

 A B C D E F G H I J K L M N O P Q R S

Unlike magic squares, which can be easily constructed if you know the trick, the solution to the Hexagon does not appear to possess any discernable regular pattern. The number of possible arrangements is a formidable 121,​645,​100,​408,​832,​000. However, since any arrangement can be rotated six times through 60 degrees, and each of these positions has a mirror image, the actual number of distinctly different arrangements is reduced to a mere 10,​137,​091,​700,​736,​000!

Inspection of the hexagon reveals one or two relationships which might help in reducing the prodigous task of finding solutions. For example, since the sum of the lines (A+​B+​C)+​(D+​E+​F+​G)+​(H+​I+​J+​K+​L)=3x38 and (A+​D+​H)+​(C+​G+​L)=​2x​38, then it follows that the remaining triangle of numbers (B+​E+​F+​I+​J+​K) must equal 38. Addition to this triangle of the line (M+​N+​O+​P) gives the large central triangle (B+​E+​F+​I+​J+​K+​M+​N+​O+​P)=​2x​38. Within this larger triangle the lines (B+​E+​I+​M) and (B+​F+​K+​P) together equal 2x38. B, which occurs in both lines, must therefore equal the small residual triangle (J+​N+​O). Similar relationships will, of course, exist in each of the 12 possible orientations of the Hexagon.

Use can be made of some of these relationships to shorten the search for a solution by trial and error. The listed program, which will run on a Nascom 1 or 2 under Nas-Sys, and could be adapted to run on any Z80 based microcomputer, systematically fills the hexagon from available numbers stored in a table at the bottom of the screen. At each position where a check can be carried out, an appropriate line or triangle of numbers is added up. If the total is 38 the program proceeds to the next position. If not, then a number is selected and the test is repeated. If the end of the table is reached without a satisfactory number being found the program retreats to the previous position and the search is continued.