Downloads
Freeware Disclaimer
The software on this site may be used freely.
You should use only if you agree to the
freeware disclaimer.
There are
Windows,
macOS, and
Linux
apps with source code files for the programs described below.
The Win c++ code is from Microsoft Visual Studio used to build the
executables for Windows.
The GNU c++ code was compiled with g++ for the macOS and Linux executables.
The Linux executables were supplied by
Holger Danielsson,
holger@danielsson.info
who has a website at
https://www.magic-squares.info/en.html.
To download and run a Windows app see
Win download.
To download and run a Mac app see
Mac download.
To download and run a Linux app see
Linux download.
Note: Run times are for a 3.0 GHz Windows PC.

Adjacent

Associative
Makes associative magic squares. For singly-even order the squares are
near-associative.
Squares are sorted in ascending order in
Frénicle standard form, with duplicates removed.
Output files are in folder AssociativeSquares[_n].

Block
Makes
block magic squares.
Prime order squares are made with 1 or 2 borders.
Some even order squares are also made with borders or bordered blocks.
Output .txt and .html files are in folder BlockSquares[_n].

Bordered
Makes
bordered magic squares.
Makes one square of each order. All these squares have zero
water retention.
Output files are in folder BorderedSquare[_n].

An earlier version using an algorithm developed for the
HP-41C
pocket calculator. The odd order squares are the same as made by BorderedSquare, but
the even squares are different, (not zero water retention).
Output files are in folder BorderedSquare[_n].

Makes
bordered magic squares.
Makes many distinct squares by randomly:
- arranging row and column value pairs, (except corners)
- rotating each border and the center
- selecting one of the 880 4x4s as center for even order squares
Squares are sorted in ascending order in
Frénicle standard form, with duplicates removed.
Output files are in folder BorderedSquares[_n].

Makes bordered magic rectangles including squares.
See
examples.
Output files are in folder BorderedRectangles[_n].
For non-square rectangles, input order as two numbers, rows columns,
(for example, 4 6

).

Makes double bordered magic rectangles including squares.
Output files are in folder DoubleBorderedRectangles[_n].
For non-square rectangles, input order as two numbers, rows columns,
(for example, 7 9

).

Nested Corner
Makes magic rectangles with nested magic rectangles at a corner.
See
examples.
Output files are in folder CornerRectangles[_n].
For non-square rectangles, input order as two numbers, rows columns,
(for example, 4 6

).
For square rectangles, it is quite slow even at orders as small as 17.
In program BorderedRectangles above, both main diagonals are naturally correct
from placement of the complementary pairs.
Here, this is true for only one of the diagonals.
The search for a combination that makes the other diagonal
correct can take a long time.
This is not a problem for non-square rectangles.

Bordering
Makes
bordering
magic squares. Output files are in folder BorderingSquares[_n].

Composite
Makes
composite
magic or Latin squares of order mn from input squares of order m and order n.
Output files are in folder <M>-<N>-CompositeSquares[_n].

Makes squares showing the content of text files as retained water. See
notes and
π r2.
Example:
Each square is a
composite of order mn
made from magic character squares of order m and a square of order n.
Order m = 11 and order n is calculated as the greater of:
- the longest text line
- the number of lines
The character squares are contained in the program.
Optionally, the program also supplies the order n square, which will be a zero
retention square. If order n is not 2, the square is magic. If the order n square is
magic, the composite is magic.
Output files are in folder <M>-<N>-Composite[_n].
Hint: The character squares can be viewed, (in output file Characters.html), by
entering a single character in the text file.

Franklin
Makes
Franklin
magic squares.
Output files are in folder FranklinNormalMagicSquares[_n].

Magic
This program makes magic rectangles. The type can be specified as semimagic,
magic, associative, concentric, or pandiagonal.
See
examples.
Pandiagonal succeeds only for small orders.
For non-square rectangles, (input order as two numbers, rows columns, for example: 5 7

).
See also
CompleteSquare.
Output files are in folder MagicRectangles[_n].

Most-perfect
Makes
most-perfect magic squares.
Output files are in folder Most-perfectSquares[_n].

Pandiagonal

Reversible
Makes principal
reversible squares. Writes to the console the number
of principal squares made and the calculated number of variations of each and total reversible squares. Output files are in folder ReversibleSquares[_n].

Self-complement
Makes side-to-side symmetric
self-complement even order magic squares.
Output files are in folder SelfComplementSquares[_n].
To make associative self-complement magic squares, use program
AssociativeSquares

Latin Squares
Makes
Latin squares and
diagonal Latin squares of various kinds.
See
notes.
Associative and near-associative are natural order \diagonal. Most other kinds are natural
order first row. Output files are in folder LS[_n].
Uses "Constraint-Based Local Search" and "Tabu Search" techniques.
See
"Water Retention on Magic Squares Solver" by Johan Öfverstedt.
Makes
Latin squares and
diagonal Latin squares including associative
and pandiagonal. Pandiagonal succeeds only for small orders. The output file is <N>x<N><square type>[_n].txt.
Converts
Latin squares to natural order first row, (nfr),
or natural order \diagonal, (nbd).
Squares are converted to nbd only if the \diagonal is a transversal.
The output file is <in file name>To<NFR|NBD>[_n].txt
Gets the \ or / diagonals from squares and sorts them in ascending order
removing duplicates.
The output file is <in file name>-[1|2]Diags[_n].txt
Finds orthogonal pairs in a file of Latin squares. There are two formats:
- 1:
- Get the counts of orthogonal pairs for each square and output these and a list of mates.
For the first square with the maximum number of pairs, output it and its mates. Files:
<in file name>-orthCounts[_n].txt
<in file name>-orthNos[_n].txt
<in file name>-<square number>orths[_n].txt.
- 2:
- Prompt for input of a square number to output with its mates. File:
<in file name>-<square number>orths[_n].txt.
A 64 bit version of GetOrthogonal.
Counts the transversals of Latin squares. Count types are:
- all: all transversals
- diagonal: transversals having exactly one element from each main diagonal
The maximum transversals is printed with the square number.
Counts are in file <N>Transversals[_n].
A 64 bit version of GetTransversals.
Makes canonical forms of diagonal Latin squares of orders 4 to 15.
There are two formats: natural order first row, (nfr), or natural order \diagonal, (nbd).
Output files are output<N>CF1[_n] or output<N>CF2[_n].
A 64 bit version of DLScanonizer.

SODLS
Makes
self-orthogonal diagonal Latin squares and their magic squares for all
valid orders, (i.e., not 2, 3, or 6).
Makes a minimum of 1 kind of SODLS for any order, many kinds for some orders.
See descriptions in
SODLS.
The kind is randomly chosen, (with bias in favor of some kinds), so it may be necessary
to enter an order many times to get a SODLS of each kind.
See also
SODLS Construction Methods.
Input is an order, (one number), or an order range, (two numbers).
Output files are in folder SODLS[_n]. Each file optionally contains:
- SODLS
- magic square
- SODLS and magic square
Makes
SODLS for small orders.
Optionally makes SSSODLS, "strong symmetric" SODLS.
Output files are SODLS<N>[_n] or SSSODLS<N>[_n].
See
notes.
Makes order 9
SODLS.
Output files are SODLS9[_n]. Uses techniques given in the 2017 paper by
Kochemazov, Vatutin, Zaikin.
Running 6 programs makes all the 224,832 SODLS with natural order first row in a little over
5 hours on a 3.0 GHz multiprocessor PC.
Makes order 10
SODLS.
Output files are SODLS10[_n].
See
notes.
Uses techniques given in the 2017 paper by
Kochemazov, Vatutin, Zaikin.

Symlateral
Makes
symlateral magic squares.
Output files are in folder SymlateralSquares[_n].

Zigzag2
Makes
zigzag2 magic squares.
For power of 2 orders, (8,16,32,...), optionally makes pandiagonal, complete,
compact
n/2 squares.
Output files are in folder ZigZag2[_n].

Order 4
Makes the 880 order 4 magic squares. Output is a .txt file.

Order 5
Makes the 275,305,224 order 5 magic squares.
Files are output in folder Order5[_n].
There are 25 .txt files, one each for the squares with the same center value.
The files contain only the squares in a single column. Numbers are separated by
white space characters, (blank, newline).
WARNING: The files are large, ranging from 341 MB to 1,492 MB, (total 21 GB).


Makes squares of any of the biggest order 5
complement pair pattern groups.
These are the 102 groups of more than 5000 squares, (ranging from 228,960 to 5,088).
An html file is also made showing the pattern of the group.
Input is a group number or number range, (2 numbers separated by a space).
Files are output in folder GroupSquares[_n].

Computes the number of order 5 magic squares. Only the source code is provided.

Order 6 Concentric
Makes 4x4 center squares and border groups.
For an input range of partitions, the output is:
- for each partition that has a 4x4 center square:
- a file of the border groups
- a file of the 4x4 center squares
- a summary file
See
Order6CDoc.txt and
Order6CExamples.txt.
Output files are in folder Order6C[_n].

Makes a sample of the squares.
One square is output for each of the center/border partitions, (22,145 squares).
Output is a .txt file.

Computes the number of order 6 concentric magic squares, (736,347,893,760).
Only the source code is provided.

Order 7
Computes the number of order 7 concentric magic squares, (3,835,791,613,181,952,000).
See
Order7CDoc.txt.
Only the source code is provided.
Makes the
order 7 bentdiagonal magic squares, (21,446).
Only the source code is provided.
It is adapted from Quick Basic program
7x7BDM-H
written by Miguel Angel Amela of Argentina.
These squares were first made by a
FormulaOne Compiler
program.

Order 8
Makes the 368,640 magic and 737,280 semi-magic order 8
Franklin
squares.
Output files are in folder Order8Franklin[_n].
Makes the 368,640 order 8
most-perfect magic squares.
Output file is Order8Most-perfectSquares[_n].txt.

Utility Programs
Input for these programs is a plain text file containing one or more number squares or
rectangles of the same order. The text file must contain only the square or rectangle numbers
separated by white space characters, (blank, horizontal tab, newline).
You will be prompted first to input the order of the squares or rectangles, and, then the
file name. The file name can be the absolute path name or the path name relative
to the folder containing the program. It is not necessary to enter the .txt
extension.
For example, on Windows, if you run program Frenicle in folder C:/Users/yourname/programs
and file order4squares.txt is in the same folder, for file name enter:
order4squares
If the file is in say C:/Users/yourname/squares, for file name enter one of:
C:/Users/yourname/squares/order4squares
../squares/order4squares
Similarly, on Linux or Mac, if program Frenicle is in folder /Users/yourname/programs,
run Terminal and enter:
cd /Users/yourname/programs
./Frenicle
If file order4squares.txt or order4squares is in the same folder, for file name enter:
order4squares
If the file is in say /Users/yourname/squares, for file name enter one of:
/Users/yourname/squares/order4squares
../squares/order4squares

Changes squares to or from
bones format.
Square numbers must be in the range 1 to n² or 0 to n²-1 for sensible results.
Non-square rectangles are also supported, (input order as two numbers, rows columns,
for example: 4 6

).
Output .html file(s) are in folder ToFromBones<RxC>[_n].
If the input file is large, output may be split into a number of files.

Given an input square with some cell values between 1 and n² specified,
(and other cell values 0), this program attempts to complete a magic square by
placing the remaining values. The square type can be semimagic, magic, or associative.
Non-square rectangles are also supported, (input order as two numbers, rows columns,
for example: 4 6

).
See
notes.
The output file is <N>x<N><square type>[_n].txt.
The program fills the starting square with random placement of unspecified values,
and then uses "Constraint-Based Local Search" and "Tabu Search" techniques to transform
the square into the indicated type.
See
"Water Retention on Magic Squares Solver" by Johan Öfverstedt.
Thanks to Craig Knecht for pushing the envelope here.
Similar to CompleteSquare, but, for successful solutions, shows the steps of the computation.
The number exchanges at each step and the intermediate squares are written to files.
See related
animation by Craig Knecht.
The maximum number of steps is set at 1000.

Copies squares from a file. Squares to copy are chosen by a number or number range.
Enter a number range as two numbers, (for example: 50 100

).
The output file is Order<N>Copy<num>[_n].txt
or Order<N>Copy<num1>to<num2>[_n].txt
Non-square rectangles are also supported, (input order as two numbers, rows columns,
for example: 4 6

).

For a file of magic rectangles, outputs a count of rectangles with each number of ponds.
Copies rectangles containing a specified number of ponds. See
water retention. For non-square rectangles, input order as two numbers, rows columns, (for example, 4 6

).
For this program, a pond is any group of contiguous wet cells.
The output file is <in file name>-<num ponds>pond(s)[_n].txt.
Hint: To output no rectangles, specify a negative number.

Copies squares from a file. Squares to copy are chosen by include and exclude
type lists.
The output file is Order<N>Copy[_n].txt.
Non-square rectangles are also supported, (input order as two numbers, rows columns,
for example: 5 7

).
See
examples.

Puts squares in
Frénicle standard form and sorts them in ascending
numerical sequence order. The number of
duplicate squares is reported and duplicates are not output.
The output file is <in file name>Frenicle[_n].txt
A 64 bit version of Frenicle that can sort much bigger files if enough RAM
is available. Requires a little over 9 GB of RAM to sort a single 21 GB file of all
the
Order5 magic squares.

Reports duplicate numbers in rectangles. Supports number range 0 to RxC, for order R by C
rectangles. For non-square rectangles, input order as two numbers, rows columns, (for example, 5 7

).

Checks if squares are magic.
The program classifies each square as normal magic, other magic, or not magic.
If the squares are not all of the same class, they are written to separate files:
NormalMagic, OtherMagic, NotMagic.
The files are written to folder Order<N>Squares[_n].

Gets the quotient and remainder squares of magic squares.
The output file is <in file name>QR[_n].txt.

Checks the type of each square as: not magic, normal semimagic, other semimagic,
normal magic, other magic.
Checks all square types for associative, pandiagonal, self-complement,
axial, symmetric, and transpose parity.
If the type is normal magic, checks other properties :
adjacent corner, adjacent side,
odd-associative, even-associative, concentric, bordered, bordering,
symlateral, ultramagic, complete, compact, bent diagonal, Franklin, zigzag,
bimagic, trimagic. If the type is normal semimagic also checks
appropriate properties in the list.
If the type is other magic, checks for prime number square and properties ultramagic, complete, compact, concentric, bimagic.
If the type is not magic, checks for reversible, pandiagonal.
Also supports non-square rectangles, (input order as two numbers, rows columns, (for example, 5 7
)).
Also supports Latin square and diagonal Latin square types and properties:
cyclic pandiagonal, semi-cyclic pandiagonal, weakly pandiagonal, ultramagic, axial symmetric,
double axial symmetric, center symmetric, orthogonal, self-orthogonal, doubly self-orthogonal,
nfr, nfc, nfr and nfc,
natural \diagonal, self-transpose.
Recognized Latin square symbols are the number ranges 0..N-1 and 1..N.
See notes.
A result summary is written to the console with details in file
<in file name>TypeDetail[_n].txt.
Same as GetType with summary results written to the console only.

Displays number rectangles with featured cells highlighted in color.
Optionally, groups of connected cells are colored differently by group size.
Highlighted feature choices are:
- non-prime numbers
- prime numbers
- odd numbers
- even numbers
- singly-even numbers
- doubly-even numbers
- numbers in the natural position
- prime numbers in the natural position
- number range
Natural position advances right, then down, starting from 1 at upper left.
For associative rectangles, with the number range feature, groups of complementary numbers
are assigned the same color as their counterpart groups.
For non-square rectangles, input order as two numbers, rows columns,
(for example, 4 6

).
Also, for "Number range, (low high)" and "Cell pixels, (width height)"
input two numbers folllowed by

.
Output .html files are in folder highLight[_n].
This feature is an idea of
Craig Knecht.

Sorts rectangles in descending or ascending order of the number of highlighted groups.
See
HighlightSquare.
The number of duplicate rectangles is reported and duplicates are not output.
For non-square rectangles, input order as two numbers, rows columns,
(for example, 5 7

).
The output file is <in file name>-<highlight name>Sort<D|A>[_n].txt. A summary file is also written.


Rotates squares to a different aspect chosen by the rotation number:
Number Rotation
-------- -----------------------------------------------------
0 none
1 clockwise 90°
2 180°
3 counterclockwise 90°
4 180° about middle vertical or Y axis, (= mirror)
5 180° about main /diagonal, (= mirror + 1)
6 180° about middle horizontal or X axis, (= mirror + 2)
7 180° about main \diagonal, (= mirror + 3)
8 all
Also supports non-square rectangles, (input order as two numbers, rows columns, (for example, 5 7
)).

Sorts rectangles in ascending or descending numerical sequence order removing duplicates. For non-square rectangles, input order as two numbers, rows columns,
(for example, 4 6

).
Rectangle aspect is not changed, so duplicates with different aspect are not removed.
Compare
Frenicle.
The output file is <in file name>Sorted<A|D>[_n].txt
A 64 bit version of SquareSort that can sort much bigger files if enough RAM is available.

Computes the sums of rows, columns, pan diagonals, and bent diagonals.
Row 1 is at the top, column 1 is on the left, diagonal 1 is always through the corners
without wrap around. Rows are numbered top to bottom, columns left to right, \diagonals left to right, /diagonals right to left, and bent diagonals in the direction of the bend.
Optionally sums 1: numbers, 2: numbers squared, or 3: numbers cubed.
Also supports non-square rectangles for rows, columns, and pan diagonals, (input order as two numbers, rows columns, (for example, 5 7
)).
The output file is <in file name>_<|Sq|Cu>Sums[_n].txt

Converts rectangles from range 0 .. to 1 .. or vice versa.
The range to convert to is indicated by input of 0 or 1.
Rectangles that are already in the selected range are copied unchanged.
Rectangles with smallest value not equal to 0 or 1 are copied unchanged.
For non-square rectangles, input order as two numbers, rows columns,
(for example, 5 7

).
The output file is <in file name>To<0|1>[_n].txt
Hint: Also useful to format a badly formatted rectangles file.

Transform
Transforms squares using
transform 1 and/or
transform 2.
For each squares file, you can do a transform and then opt to do another transform of
that transform. If declined, you can opt to do another transform on the original squares.
If declined, you can opt to transform another file of squares. The transform is selected
by the number of rows entered, (1 or 2).
The flow chart is:
--------------->--------- enter the order
^ |
| enter the file name
| |
| ----------->--------- enter the rows(s)
| ^ ^ |
| | | transform squares
| | | |
| | <- YES <- transform transformed squares?
^ ^ |
| | NO
| | |
| <----- YES <--- transform original squares?
| |
| NO
| |
<--------- YES <----- transform another file?
|
NO
|
end

For each square in an input file, makes (a sample of) all possible squares from
repeated
transform 1
and/or
transform 2.
Output files are in folder Order<N>XForm[_n].
There is one file for each square in the input file.
The first square in each output file is the original square.

Makes the
complementary squares.
The output file is <in file name>Complement[_n].txt.
Self-complement squares are also written to <in file name>SelfComplement[_n].txt.
Also supports non-square rectangles, (input order as two numbers, rows columns,
(for example, 4 6

).

For doubly even orders, transforms
associative magic squares to or from
pandiagonal complete
magic squares. Pandiagonal complete squares are written to
<in file name>P[_n].txt.
Associative squares are written to <in file name>A[_n].txt.
All squares are output in
Frénicle standard form, (unsorted).


For doubly even orders, transforms
reversible squares to and from
most-perfect squares. Most-perfect squares are written to
<in file name>MP[_n].txt.
Reversible squares are written to <in file name>R[_n].txt.
Optionally, unique squares are made. See
notes.
With this option, the most-perfect square is in
Frénicle standard form
and the reversible square aspect is also outout.



Water Retention
Computes and displays the water retention patterns of number rectangles.
For non-square rectangles, input order as two numbers, rows columns,
(for example, 4 6

).
Water retention is an idea of
Craig Knecht.
The program is based on an algorithm of
Gareth McCaughan.
See requirements for the input file under the Utility Programs heading.
An example text file of the 880
order 4 magic squares
is provided.
Output .html files are in folder Water<N>[_n]. If the input file is large, output
may be split into a number of files. Here is an output example:
There is an option to color the water areas by size in the Units square:


Displays a 3-dimensional view of water retention.
For non-square rectangles, input order as two numbers, rows columns,
(for example, 5 7

).
The code for the 3D view was
written by
Claudio Rocchini during the
Zimmermann contest.
Land is shown in shades of
green,
water in
blue, and the start of spillways between water bodies or out of
the square in
yellow. For water, the bottom elevations are shown.
Here are examples:

Output files are in folder Water<N>_3D[_n].
The files are in
Scalable Vector Graphics (SVG) format.
There is one .svg file for each square in the input file.
You may need to install a viewer like Win 98-XP from
Adobe,
before your browser will open .svg files.
Another way is to download and run a program such as
Windows - installer from
Inkscape.
With Inkscape you can open a .svg file and save it as a .png.

Sorts rectangles in decreasing or increasing order of water retention.
For non-square rectangles, input order as two numbers, rows columns,
(for example, 4 6

).
The number of duplicate rectangles is reported and duplicates are not output.
The output file is <in file name>WRsort[_n].txt.
A summary file is also written.

For an input file of squares, finds the maximum water retention for a square and its complement. The square(s) and complement(s) having the maximum combined retention
are written to a file. For self-complement squares, the square with the maximum retention
is written to a file. A summary is written to the console and a file.
The output files are in folder WRwithComplement<N>[_n].