Your task is to build a program that identifies the shape of the input. The shapes to be identified can be any of the following:
Square
To be identified as a square, the source must have lines of all equal length, and the same number of lines as characters per line (newline characters excluded). An optional trailing newline is acceptable.
$_='
$_="
$_"'
;say
Rectangle
To be identified as a rectangle, the source must have lines of all equal length, but the number of lines does not match the number of characters per line (newline characters excluded). An optional trailing newline is acceptable. This can be either horizontal or vertical.
$_=
"no
t a
squ
are
";#
$_="but it
is still a
consistent
shape!";##
Triangle
To be identified as a triangle, the source must either start with one character, and each subsequent line must have one additional character (including the last), or after the first line, each subsequent line should have one character fewer until the last, which has only one.
$
_=
"So
this
"."".
shape;
$_="or
even,
this
way
!!
"
Mess
Anything that doesn't follow a consistent format as per the above, must be identified as a mess.
Rules
- You may return any four consistent printable values to identify each shape.
- Your source code must also adhere to one of the above shapes (no, not a mess).
- A single trailing newline in your source is acceptable.
- You can assume input does not contain any blank lines (including trailing newlines), is not empty, and does not consist only of newlines.
- All shapes must have a height and width of >= 2, otherwise this is defined as a mess.
- Standard loopholes are forbidden.
- The shortest solution in bytes, in each language, wins.
All shapes must have a height and width of >= 2.
\$\endgroup\$['abc','cfd','fgh']
? \$\endgroup\$