# BotClean Large – HackerRank Solution

In this post, we will solve BotClean Large HackerRank Solution. This problem (BotClean Large) is a part of HackerRank Artificial Intelligence series.

## Solution – BotClean Large – HackerRank Solution

### Python

```import math

# Update cost that bot need to arrive the dirty
def update_position(posr, posc, dirties):
nearest_dirt = []
for i in range(len(dirties)):
# Euclidean distance
result = math.sqrt(((dirties[i] - posr) ** 2) + ((dirties[i] - posc) ** 2))
nearest_dirt.append(result)
return [x for (y,x) in sorted(zip(nearest_dirt,dirties))]

# Set the bot in your new position
def next_move(posx, posy, dimx, dimy, board):
dirties = []
for i in range(dimx):
for j in range(dimy):
if board[i][j] == 'd':
dirties.append([i, j])

next_dirt = update_position(posx, posy, dirties)
if next_dirt < posx:
print('UP')
elif next_dirt > posx:
print('DOWN')
elif next_dirt < posy:
print('LEFT')
elif next_dirt  > posy:
print('RIGHT')
else:
print('CLEAN')

# Set data
if __name__ == "__main__":
pos = [int(i) for i in input().strip().split()]
dim = [int(i) for i in input().strip().split()]
board = [[j for j in input().strip()] for i in range(dim)]
next_move(pos, pos, dim, dim, board)
```

Note: This problem (BotClean Large) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.