Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 284 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina, 57112 bytes

^\s+¶|¶\s+$
/^( .*¶)+ .*$/+m`^ 
/^(.* ¶)+.* $/+m` $
/^#* /&G^`
/(?m)^ /&V`
/^##+(¶#.*)+/+`^#+¶#|(¶)#
1ドル
^\s+$

Try it online! Try it online! Link includes test suite with header that extracts the #-based test cases from the input and automatically right-pads them. Explanation:

^\s+¶|¶\s+$
/^( .*¶)+ .*$/+m`^ 
/^(.* ¶)+.* $/+m` $

Remove any margins. Annoyingly, this costs almost 50% of the code size.

/^#* /&G^`

If the first line contains a space then reverse the rows.

/(?m)^ /&V`

If the first column contains a space then reverse each line.

/^##+(¶#.*)+/+`

Repeat while the there are at least two rows and columns of which the first of each only contains #s...

^#+¶#|(¶)#
1ドル

... completely delete the first row and column.

^\s+$

Check that the entire L was deleted.

Retina, 57 bytes

/^#* /&G^`
/(?m)^ /&V`
/^##+(¶#.*)+/+`^#+¶#|(¶)#
1ドル
^\s+$

Try it online! Link includes test suite with header that extracts the #-based test cases from the input and automatically right-pads them. Explanation:

/^#* /&G^`

If the first line contains a space then reverse the rows.

/(?m)^ /&V`

If the first column contains a space then reverse each line.

/^##+(¶#.*)+/+`

Repeat while the there are at least two rows and columns of which the first of each only contains #s...

^#+¶#|(¶)#
1ドル

... completely delete the first row and column.

^\s+$

Check that the entire L was deleted.

Retina, 112 bytes

^\s+¶|¶\s+$
/^( .*¶)+ .*$/+m`^ 
/^(.* ¶)+.* $/+m` $
/^#* /&G^`
/(?m)^ /&V`
/^##+(¶#.*)+/+`^#+¶#|(¶)#
1ドル
^\s+$

Try it online! Link includes test suite with header that extracts the #-based test cases from the input and automatically right-pads them. Explanation:

^\s+¶|¶\s+$
/^( .*¶)+ .*$/+m`^ 
/^(.* ¶)+.* $/+m` $

Remove any margins. Annoyingly, this costs almost 50% of the code size.

/^#* /&G^`

If the first line contains a space then reverse the rows.

/(?m)^ /&V`

If the first column contains a space then reverse each line.

/^##+(¶#.*)+/+`

Repeat while the there are at least two rows and columns of which the first of each only contains #s...

^#+¶#|(¶)#
1ドル

... completely delete the first row and column.

^\s+$

Check that the entire L was deleted.

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina, 57 bytes

/^#* /&G^`
/(?m)^ /&V`
/^##+(¶#.*)+/+`^#+¶#|(¶)#
1ドル
^\s+$

Try it online! Link includes test suite with header that extracts the #-based test cases from the input and automatically right-pads them. Explanation:

/^#* /&G^`

If the first line contains a space then reverse the rows.

/(?m)^ /&V`

If the first column contains a space then reverse each line.

/^##+(¶#.*)+/+`

Repeat while the there are at least two rows and columns of which the first of each only contains #s...

^#+¶#|(¶)#
1ドル

... completely delete the first row and column.

^\s+$

Check that the entire L was deleted.

AltStyle によって変換されたページ (->オリジナル) /