Skip to main content
deleted 77 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 1515 12 bytes

4:"3tYL@X!0cyPytP

Try it online!Try it online! Outputs all matrices without separation. Note that the output is unambiguous.

Alternatively, this version uses a line as separator, for 15 bytes.

How it works

4:      % Range [1 2 3 4]
"       % For each k in that range
  3tYL  %   Magic square of size 3 (gives one of the 8 possible squares)
  @     %   Push k
  X!    %   Rotate matrix 90 degrees k times
  0c    %   Push character 0 (displayed as space). Used as separator
  yt     %   Duplicate from above: pushes copy of the latest matrix
  P     %   Flip vertically
  y     %   Duplicate from above: pushes character 0 again
        % End (implicit)
        % Display stack, bottom to top (implicit)

MATL, 15 bytes

4:"3tYL@X!0cyPy

Try it online!

How it works

4:      % Range [1 2 3 4]
"       % For each k in that range
  3tYL  %   Magic square of size 3 (gives one of the 8 possible squares)
  @     %   Push k
  X!    %   Rotate matrix 90 degrees k times
  0c    %   Push character 0 (displayed as space). Used as separator
  y     %   Duplicate from above: pushes copy of the latest matrix
  P     %   Flip vertically
  y     %   Duplicate from above: pushes character 0 again
        % End (implicit)
        % Display stack, bottom to top (implicit)

MATL, 15 12 bytes

4:"3tYL@X!tP

Try it online! Outputs all matrices without separation. Note that the output is unambiguous.

Alternatively, this version uses a line as separator, for 15 bytes.

How it works

4:      % Range [1 2 3 4]
"       % For each k in that range
  3tYL  %   Magic square of size 3 (gives one of the 8 possible squares)
  @     %   Push k
  X!    %   Rotate matrix 90 degrees k times
  t     %   Duplicate
  P     %   Flip vertically
        % End (implicit)
        % Display stack, bottom to top (implicit)
added 540 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 15 bytes

4:"3tYL@X!0cyPy

Try it online!

How it works

4:      % Range [1 2 3 4]
"       % For each k in that range
  3tYL  %   Magic square of size 3 (gives one of the 8 possible squares)
  @     %   Push k
  X!    %   Rotate matrix 90 degrees k times
  0c    %   Push character 0 (displayed as space). Used as separator
  y     %   Duplicate from above: pushes copy of the latest matrix
  P     %   Flip vertically
  y     %   Duplicate from above: pushes character 0 again
        % End (implicit)
        % Display stack, bottom to top (implicit)

MATL, 15 bytes

4:"3tYL@X!0cyPy

Try it online!

MATL, 15 bytes

4:"3tYL@X!0cyPy

Try it online!

How it works

4:      % Range [1 2 3 4]
"       % For each k in that range
  3tYL  %   Magic square of size 3 (gives one of the 8 possible squares)
  @     %   Push k
  X!    %   Rotate matrix 90 degrees k times
  0c    %   Push character 0 (displayed as space). Used as separator
  y     %   Duplicate from above: pushes copy of the latest matrix
  P     %   Flip vertically
  y     %   Duplicate from above: pushes character 0 again
        % End (implicit)
        % Display stack, bottom to top (implicit)
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 15 bytes

4:"3tYL@X!0cyPy

Try it online!