def valid(x, y, passed):
    """
    This function check if the index is in the valid area.
    :param x: row index of a character
    :param y: column index of a character
    :param passed: a switch used to check if a character have been visited.
    :return: bool
    """
    return (0 <= x < 4) and (0 <= y < 4) and not passed[x][y]