Recently asked a variation of number of islands in a codility OA
Question. Given array of grid matrix, a robot need to clean the entire plan of floors
A clean floor is marked by "." and dirty floor is marked by "*" where is "#" is a wall. A robot can move 4 directions in a grid up, down, bot, left. Determine the minimum run robots needs to do to clean the entire grid. The robot can only move on block containing "." (clean grid) or "*" (dirty grid).
Edge case if connected clean floor doesn't have dirty sport, the robot won't run those spots (test case no 4 for reference)
couple of input test cases
['.#..', '.#.#', '######', '...#.', '...###'], output = 3
['#..', '#..#', '.##.', '...'] , output = 2
['###', '###', '#####', '#**#', '.#####.', '..#..'], out = 5
['.....', '#####', '....*'], out = 1
where ROWS = len(grid) and Cols = len(grid[0]).