Background
An L-shape is defined as a polyomino which can be made by extending two rectangular legs in orthogonal directions from a full square (called a pivot). The size of the square should be at least 1, and the lengths of the two legs should also be at least 1.
These are some examples of L-shapes:
Pivot size 1, two leg lengths 2 and 4
#
#
#####
Pivot size 2, two leg lengths 1 and 3
#####
#####
##
These are not:
Does not have two orthogonal nonempty legs
####
The pivot is not a square
##
####
One of the legs is not rectangular
#####
####
##
##
Has three legs instead of two
#####
#####
##
Has four legs instead of two
#
#######
#
#
Cannot identify a pivot and two legs
##
##
Contains one or more holes
#####
# ###
#####
# #
###
Is not a polyomino (the shape is disconnected)
## #
# ##
Challenge
Given a zero-one matrix, determine if the ones form a single L-shape.
You should handle inputs containing any amount of margins on all four sides (including no-margin cases), and detect L-shapes in any of the four orientations. For example, the output must be True if the input is any of these:
0 0 1 1 1 1 0
0 0 1 1 1 1 0
0 0 1 1 0 0 0
1 1 1
0 0 1
0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 0 0 0
0 0 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 1 1 0
1 1 1 1 1 0
1 1 1 1 1 0
0 0 0 0 0 0
0 0 0 0 0 0
and False if given any of these:
1
0 0 0 0
0 1 1 0
0 1 1 0
0 0 0 0
1 0 1
0 0 0
1 0 0
0 0 0 1
0 1 1 1
0 0 1 0
0 0 0 0
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 1 1 1 0 0
1 1 0 0
1 1 1 1
You can choose any reasonable representation of a matrix, and you can assume that the input is always rectangular. You can also choose the two values to represent 0 and 1 respectively.
For output, you can choose to
- output truthy/falsy using your language's convention (swapping is allowed), or
- use two distinct, fixed values to represent true (affirmative) or false (negative) respectively.
Shortest code in bytes wins.
"001\n111\n000\n001" -> false
\$\endgroup\$0
s doesn't affect whether the input is true/false, so inputting as a list of integers should be possible (for example) by stripping margins which are fully zero \$\endgroup\$