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.
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.