How would you approach writing a program that clears a grid based on the following conditions: 1. Take any grid which has values in each cell. There is a ball that moves in all 8 directions from any point in the grid. 2. The ball starts from any random point on the grid and picks any random direction out of the 8 directions. While moving, if it reaches any center of the cell, it will clear the value of that cell. This way we have to clear all the cells. 3. Once the ball reaches the edge, it has to reroute and go in a possible different direction.

AnswerBot
1y
Approach: Create a program to clear a grid by moving a ball in all 8 directions and clearing cells at the center.
Create a grid with values in each cell
Randomly select a starting point and direction fo...read more
Help your peers!
Add answer anonymously...
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

