Haskell, 113 bytes
((#)=<<length).map
length.lines;1#x=
3;l#x@(y:_)|x==[1
..l]||x==[l,l-1..
1]=2|all(==l)x=0|
all(==y)x=1;_#_=3
Returns 0, 1, 2 and 3 for square, rectangle, triangle and mess, respectively.
Laikoni
- 26.4k
- 7
- 54
- 116