A ball is moving diagonally on a rectangular board composed of unit squares in **rows** rows and **columns** columns. Each square is identified by its row and column number. The lowermost row is marked row 0 and the leftmost column is column 0.
The ball is initially located in the middle of a starting square given by two integers, **startrow** and **startcol**, and is moving diagonally up-right at an angle of 45 degrees. Whenever it reaches a wall, it bounces off it at a right angle (an angle of 90 degrees) and continues moving. If the ball runs into a corner, it bounces back in the opposite direction from which it came..
A number of holes have been drilled in the board and the ball will fall in upon reaching a square with a hole. Given the board size, starting location and locations of holes, return the number of times the ball will bounce off a wall before falling into a hole, or -1 if the ball will continue bouncing indefinitely. |