Skip to main content
deleted 19 characters in body
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 4343 35 bytes

WS⊞υLι≔υθ≔⁰ηW⊙θ⁻κLΦθ›μλ«≦⊕η≔⁺Eη⁺ηLΦυ›μλυθ»θWS⊞υLι§ΦE⊕⌈υ⁺Eι⁺ιLΦυ›νμυ⬤ι⁼λLΦι›νμ⁰

Try it online!Try it online! Link is to verbose version of code. I/O is as a Young Diagram using -s as the fill character. Explanation:

WS⊞υLι

Input the diagram.

≔υθ

Start testing the diagram itself in case it is already symmetric.

≔⁰η

Start testing symmetry about the main diagonal.

W⊙θ⁻κLΦθ›μλ«

Until the diagram is symmetric, ...

≦⊕ηE⊕⌈υ

... increase the For each possible number of rows from 0 to be prepended, andthe length of the first row (inclusive)...

≔⁺Eη⁺ηLΦυ›μλυθ⁺Eι⁺ιLΦυ›νμυ

... calculate the transpose of that number of columns, concatenating with the original input.

»θ§Φ...⬤ι⁼λLΦι›νμ⁰

OutputPrint the finalfirst symmetric diagramresult.

Example: At each stage, an extra rowi-by-i square is prepended, and the extra rows are filled so that they are the transpose ofprefixed to the columnsoriginal input (marked here usingby # signs) and then extended by transposition (marked by = signs), at which point it remains to check that the remainder of the diagram its its own transpose, although it's golfier to check. The first symmetric result is then the whole diagram each timeone with 3 prefixed rows.

                           ======             #####===
                  =====    =====          ####=== #####==
         ====     ====     =====     ###===  ####==  #####==
                ##===   ###==   ####==  #####==
        #===    ##==    ###==   ####==  #####=
----- ->  =---- ->  ==--- ->  ===--   ====-   =====
----     =---     ==--     ===-    ====    ====
-        =       =       =       =       =
0       1       2       3       4       5

Charcoal, 43 bytes

WS⊞υLι≔υθ≔⁰ηW⊙θ⁻κLΦθ›μλ«≦⊕η≔⁺Eη⁺ηLΦυ›μλυθ»θ

Try it online! Link is to verbose version of code. I/O is as a Young Diagram using -s as the fill character. Explanation:

WS⊞υLι

Input the diagram.

≔υθ

Start testing the diagram itself in case it is already symmetric.

≔⁰η

Start testing symmetry about the main diagonal.

W⊙θ⁻κLΦθ›μλ«

Until the diagram is symmetric, ...

≦⊕η

... increase the number of rows to be prepended, and...

≔⁺Eη⁺ηLΦυ›μλυθ

... calculate the transpose of that number of columns, concatenating with the original input.

»θ

Output the final symmetric diagram.

Example: At each stage an extra row is prepended, and the extra rows are filled so that they are the transpose of the columns (marked here using = signs), at which point it remains to check that the remainder of the diagram its its own transpose, although it's golfier to check the whole diagram each time.

                           ======
                  =====    =====
         ====     ====     =====
----- -> =---- -> ==--- -> ===--
----     =---     ==--     ===-
-        =        =        =

Charcoal, 43 35 bytes

WS⊞υLι§ΦE⊕⌈υ⁺Eι⁺ιLΦυ›νμυ⬤ι⁼λLΦι›νμ⁰

Try it online! Link is to verbose version of code. I/O is as a Young Diagram using -s as the fill character. Explanation:

WS⊞υLι

Input the diagram.

E⊕⌈υ

For each possible number of rows from 0 to the length of the first row (inclusive)...

⁺Eι⁺ιLΦυ›νμυ

... calculate the transpose of that number of columns, concatenating with the original input.

§Φ...⬤ι⁼λLΦι›νμ⁰

Print the first symmetric result.

Example: At each stage, an i-by-i square is prefixed to the original input (marked by # signs) and then extended by transposition (marked by = signs). The first symmetric result is then the one with 3 prefixed rows.

                                        #####===
                                ####=== #####==
                        ###===  ####==  #####==
                ##===   ###==   ####==  #####==
        #===    ##==    ###==   ####==  #####=
-----   =----   ==---   ===--   ====-   =====
----    =---    ==--    ===-    ====    ====
-       =       =       =       =       =
0       1       2       3       4       5
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 43 bytes

WS⊞υLι≔υθ≔⁰ηW⊙θ⁻κLΦθ›μλ«≦⊕η≔⁺Eη⁺ηLΦυ›μλυθ»θ

Try it online! Link is to verbose version of code. I/O is as a Young Diagram using -s as the fill character. Explanation:

WS⊞υLι

Input the diagram.

≔υθ

Start testing the diagram itself in case it is already symmetric.

≔⁰η

Start testing symmetry about the main diagonal.

W⊙θ⁻κLΦθ›μλ«

Until the diagram is symmetric, ...

≦⊕η

... increase the number of rows to be prepended, and...

≔⁺Eη⁺ηLΦυ›μλυθ

... calculate the transpose of that number of columns, concatenating with the original input.

»θ

Output the final symmetric diagram.

Example: At each stage an extra row is prepended, and the extra rows are filled so that they are the transpose of the columns (marked here using = signs), at which point it remains to check that the remainder of the diagram its its own transpose, although it's golfier to check the whole diagram each time.

                           ======
                  =====    =====
         ====     ====     =====
----- -> =---- -> ==--- -> ===--
----     =---     ==--     ===-
-        =        =        =