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