Let's learn geometry Today our lesson is about rectangles and triangles.

you will be given as an input an n x n grid that is based on two characters # and *
you have to classify it into :  triangle or rectangle.
where # represents a point and * represents a blank space.

Example input:

 #***
 ##**
 ###*
 ####


Output:

 triangle


Another example

  ##**
  ##**
  ##**
  ##**


Output:

  rectangle


Rules:


You should assume that the input is always either a triangle or a rectangle.
The only two characters you will receive are: * and #.
Assume that n &lt; 100.
Be creative, this is a popularity-contest so the most up-voted answer will win.
TSQL

Image recognition? Sounds like a job made for SQL :)

WITH cte AS (
  SELECT LEN(data)-LEN(REPLACE(data,'#','')) c FROM test_t
)
SELECT 
  CASE WHEN COUNT(DISTINCT c)&gt;2                           THEN 'triangle' 
       WHEN SUM(CASE WHEN c=0 THEN 0 ELSE 1 END) = MAX(c) THEN 'square'
                                                          ELSE 'rectangle'
       END result
FROM cte;


An SQLfiddle with sample data and test.