Skip to main content
3 of 3
added 855 characters in body
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 16 bytes

“ÑṆ6Ẉ’Ds3ZU$Ƭ;U$

A niladic Link that yields a list of eight lists of lists of digits, the eight magic squares.

Try it online!

How?

Builds one then constructs the other seven using rotations and reflections.

“ÑṆ6Ẉ’Ds3ZU$Ƭ;U$ - Link: no arguments
“ÑṆ6Ẉ’           - base 250 literal = 276951438
      D          - decimal digits -> [2,7,6,9,5,1,4,3,8]
       s3        - split into threes -> [[2,7,6],[9,5,1],[4,3,8]]
            Ƭ    - collect up until a fixed point is found under:
           $     -   last two links as a monad - f=rotate(current):
         Z       -     transpose - i.e. swap rows with columns
          U      -     upend - i.e. reverse each row
               $ - last two links as a monad - f=add_reflections(four_rotations):
              U  -   upend - i.e. revese each row of each rotation
             ;   -   (four_rotations) concatenate (upended)

Alternatives

⁽Xð×3Œ?s3ZU$Ƭ;U$
“=ẹʋ‘×3D‘ZU$Ƭ;U$
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282