The Solution:
To solve this problem, we are going to use something called the Ray Casting algorithm. This algorithm works by casting a line from the point we are asking about (the “Test Point”) towards the right, left, top or bottom direction. Then, counting how many times this line i...