Micropower |
Volume 1 · Number 4 · December 1981 |
| Page 23 of 33 |
|---|
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,
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+
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.
| Page 23 of 33 |
|---|