def command(cords, new_coords):
    """
    returning a command for moving miner to new_coord
    """
    delta = [cords[i] - new_coords[i] for i in range(2)]
    if delta[0] == -1:
        return "right"
    elif delta[0] == 1:
        return "left"
    elif delta[1] == -1:
        return "down"
    else:
        return "up"

    
def neighbors(coords):
     """
     returning a tuple of indexes of neighbors cells
     """
     return [[coords[0] - 1, coords[1]], [coords[0] + 1, coords[1]], [coords[0], coords[1] - 1], [coords[0], coords[1] + 1]]

def solve(map, miner, exit):
  commands = []
  passed = []
  x, y = miner['x'], miner['y']
  while (x, y) != (exit['x'], exit['y']):
      neighs = neighbors([x, y])
      for neigh in neighs:
        if neigh not in passed and neigh[0] >= 0 and neigh[1] >= 0 :
            tr:y
                if map[neigh[0]][neigh[1]] is True:
                    commands.append(command([x, y], [neigh[0], neigh[1]]))
                    passed.append([x, y])
                    x, y = neigh[0], neigh[1]
            except Exception as e:
                continue
  return commands

Add a code snippet to your website: www.paste.org