## Question:

There is a task to determine the type of figure (square or circle) in the matrix. The matrix is written to a text file as 15 lines of 15 characters each, the diameter of a circle or the side of a square can be from 5 to 10 characters inclusive:

```
000000000000000
000111111000000
000111111000000
000111111000000
000111111000000
000111111000000
000111111000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
```

Please tell me if there are any methods for determining such figures. I want to do the implementation myself, I just don't want to reinvent the wheel. I plan to write in `C++`

under `Windows`

, with a minimum of third-party libraries.

## Answer:

Let's fantasize 🙂

If the square always stands vertically (horizontally) and the diameter of the circle will not be less than 3, then such a heuristic will do.

We take the leftmost point, in which there is a unit, from such identical points we select the topmost one. We go to the right by ones and look: if at some point it turned out that there is a unit above and below our current position, then this is a circle. If not found, then it is a square.

This is the usual ray tracing method, only very simplified.