Using python
There is a cleaning robot which is cleaning a rectangular grid of size NxM, represented by array R consisting of N strings. Rows are numbered from 0 to N1 (from top to bottom) and columns are numbered from 0 to M1 (from left to right). The robot starts cleaning in the top-left comer, facing rightwards. It moves in a straight line for as long as it can, in other words, while there is an unoccupled grid square ahead of it. When it cannot move forward, it rotates 90 degrees clockwise and tries to move forward again until it encounters another obstacle, and so on. Dots in the array (".") represent empty squares and " x "s represent occupied squares (ones the robot cannot move through). Each square that the robot occupied at least once is considered clean. The robot moves indefinitely. Write a function: def solution( (i) that, given an array R consisting of N strings, each of length M, representing the grid, retums the number of clean squares. Examples: 1. Glven A=[x.....xx,x.] your function should retum 6. The robot starts at (0,0), facing rightwards, and moves to (0,2), where it turns due to the obstacle at (0,3). Then it goes down from (0,2) to (1,2), where it changes direction again due to another obstacle. Next it goes left from (1,2) to (1,0), where it turns once because of the grid boundary, then it moves once and tums once more, which makes it stand again at position (0,0) facing rightwards, just as at the beginning, which means it will now repeat the loop indefinitely. The total number of cleaned squares is 6. The robot starts at (0,0), facing rightwards, and moves to (0,2), where it turns due to the obstacle at (0,3). Then it goes down from (0,2 to (1,2), where it changes direction again due to another obstacle. Next it goes left from (1,2) to (1,0), where it turns once because of the grid boundary, then it moves once and turns once more, which makes it stand again at position (0,0) facing rightwards, Just as at the beginning, which means it will now repeat the loop indefinitely. The total number of cleaned squares is 6. 2. Given A=[.... Z. your function should retum 15. 3. Given A=[..,x.,x,x..,x,x..1 your function should retum 9. 4. Given A=[.. your function should retum 1 , because there is only one square on the grid and it is cleaned in the first move. Assume that: - N and M are integers within the range [1..20]; - top-left cell is empty, - each string in R consists only of the following characters:" ". and/or x. In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment