Vlad and Shapes

Given an n x n grid containing exactly one shape, classify it as SQUARE or TRIANGLE. A square has k consecutive rows each containing the same k consecutive 1 characters. A triangle has consecutive row widths 1,3,5,... or the reverse, centered in one column. The shape size is greater than one.

Examples
Input: [1,2,3]
Output: 0
Hints

Vlad and Shapes

Given an `n x n` grid containing exactly one shape, classify it as `SQUARE` or `TRIANGLE`. A square has `k` consecutive rows each containing the same `k` consecutive `1` characters. A triangle has consecutive row widths `1,3,5,...` or the reverse, centered in one column. The shape size is greater than one.