Revision 8fc60b45-3e1d-4921-95da-57e872f7c55c - Code Golf Stack Exchange
# [Stax](https://github.com/tomtheisen/stax), 39 bytes
L{%m~;:-c:u{hJchC;
|mb1=-C;%a\sI^^P}M0
[Run and debug online!](https://staxlang.xyz/#c=L%7B%25m~%3B%3A-c%3Au%7BhJchC%3B+%0A%7Cmb1%3D-C%3B%25a%5CsI%5E%5EP%7DM0&i=L%7B%25m~%3B%3A-c%3Au%7BhJchC%3B+%0A%7Cmb1%3D-C%3B%25a%5CsI%5E%5EP%7DM0%0A%0A%24_%3D%27%0A%24_%3D%22%0A%24_%22%27%0A%3Bsay%0A%0A%24_%3D%22but+it%0Ais+still+a%0Aconsistent%0Ashape%21%22%3B%23%23%0A%0A%24%0A_%3D%0A%22So%0Athis%0A%22.%22%22.%0Ashape%3B%0A%0A%24_%3D%22or%0Aeven,%0Athis%0Away%0A%21%21%0A%22%0A%0Ashape%3B%0A%24_%3D%22or%0Aeven,%0Athis%0Away%0A%21%21%0A%22%0A%0Ashape%3B%0A%0As%0Ah%0Aa%0Ap%0Ae%0A%3B&a=1&m=1)
Shortest ASCII-only answer so far.
> 0 - Mess <br />
> 1 - Rectangle <br />
> 2 - Square <br />
> 3 - Triangle <br />
## Explanation
The solution makes use of the following fact: If something is explicitly printed in the execution of the program, no implicit output is generated. Otherwise, the top of stack at the end of the execution is implicitly output.
L{%m~;:-c:u{hJchC;|mb1=-C;%a\sI^^P}M0
L Collect all lines in an array
{%m Convert each line to its length
~; Make a copy of the length array, put it on the input stack for later use
:- Difference between consecutive elements.
If the original array has only one line, this will be an empty array
c:u Are all elements in the array the same?
Empty array returns false
{ }M0 If last test result is true, execute block
If the block is not executed, or is cancelled in the middle, implicitly output 0
hJ The first element of the difference array squared (*)
chC Cancel if it is not 0 or 1
;|m1= Shortest line length (**) is 1
- Test whether this is the same as (*)
Includes two cases:
a. (*) is 1, and (**) is 1, in which case it is a triangle
b. (*) is 0, and (**) is not 1, in which case it is a square or a rectangle
C Cancel if last test fails
;% Number of lines
a\ [Nr. of lines, (*)]
I Get the 0-based index of (**) in the array
0-> Square, 1->Triangle -1(not found) -> Rectangle
^^P Add 2 and print