So this is my task:

You are given an irregular shape on a bitmap. How do you determine if

a point is inside or ousdie of the shape?

We are allowed to assume that `helper functions`

are already available for us and we don’t need to write them as well.

So I decided that I can use a function that returns me the status of a given bit on that bitmap.

```
int IsBitIsOn(bitmap_ty *bitmap, size_t x, size_t y);
```

**We also can assume that the given point won’t be a point on the outline of the shape. Which means the given X,Y coordinates must be either inside or outside the shape and not on one of the outlines.**

And here is my full code of the task,

I wrote it as a bitmap that every `ON(==1)`

bit tells me that I’m on an outline, while `0 bit`

tells me i’m either `inside`

or `outside`

the shape.

```
int IsInTheShape(bitmap_ty *bitmap, size_t x, size_t y)
{
int IsIn = 0; /* flag of whether the given point is inside the shape */
int ComeFromAbove = 0;
int start_sequal = 1;
size_t curr_row = y;
size_t curr_column = 0;
while (x != curr_column)
{
if (IsBitIsOn(bitmap, curr_column, curr_row))
{
IsIn = !IsIn;
/* starts a sequal of bits that are ON */
while (IsBitIsOn(bitmap, curr_column + 1, curr_row))
{
/* checks the source direction of the first bit in the sequal */
if (start_sequal &&
IsBitOn(bitmap, curr_column, curr_row - 1) ||
isBitOn(bitmap, curr_column - 1, curr_row - 1) ||
isBitOn(bitmap, curr_column + 1, curr_row - 1))
{
ComeFromAbove = 1;
start_sequal = 0;
}
++curr_column;
}
/* checks the source direction of the last bit in the sequal,
so if it cuts the direction of the first bit, it means
the next points are out of the shape */
if (ComeFromAbove)
{
if (!IsBitOn(bitmap, curr_column, curr_row + 1) &&
!isBitOn(bitmap, curr_column - 1, curr_row + 1) &&
!isBitOn(bitmap, curr_column + 1, curr_row + 1))
{
ComeFromAbove = 0;
IsIn = !IsIn;
}
}
}
++curr_column;
}
return (IsIn);
}
```

**I draw the following shapes find the problematic points and shapes:**