Create a magic square of order three in your terminal.
"Magic square" is the name given to a square array of numbers if the sums of the numbers in each row, each column, and both main diagonals are the same; the number that each sum gives is called the "magic constant". "Order" is the number of integers along one side. (Wikipedia)
To use magic-square
, you need to download the executable (.exe
) file in the Releases page and use it via the command-line.
$ magic-square A B C [--style STYLE]
where
A
is a positive integer:A > 0
;B
is an integer greater thanA
and not equal to the double ofA
:B > A && B /= 2 * A
;C
is an integer greater thanB
plusA
:C > B + A
;STYLE
prints the magic square with the chosen style (--styles-list
shows available styles).
$ magic-square 1 5 9
4 | 15 | 8
------------
13 | 9 | 5
------------
10 | 3 | 14
$ magic-square 1 3 5 -sMinimal
2 9 4
7 5 3
6 1 8
$ magic-square 1 4 7 -sPlus
3 + 12 + 6
++++++++++++
10 + 7 + 4
++++++++++++
8 + 2 + 11
$ magic-square 2 3 8 -sBox
5 || 13 || 6
##############
9 || 8 || 7
##############
10 || 3 || 11
$ magic-square 1 6 9 -sArray
[[ 3, 16, 8],
[14, 9, 4],
[10, 2, 15]]