32-04-Ngô Huỳnh Kiều Nga
32-04-Ngô Huỳnh Kiều Nga
image[x][y] = replacement_color
if image[x][y] == target_color:
image[x][y] = replacement_color
# Example Usage:
image = [
[1, 1, 1, 1, 1],
[1, 0, 0, 1, 1],
[1, 0, 0, 0, 1],
[1, 1, 1, 1, 1],
]
boundary_fill(image, 1, 2, 0, 2)
if image[x][y] == target_color:
image[x][y] = replacement_color
q = Queue()
q.put((start_x, start_y))
visited.add((x, y))
if image[x][y] == target_color:
image[x][y] = replacement_color
# Example Usage:
image = [
[1, 1, 1, 1, 1],
[1, 0, 0, 1, 1],
[1, 0, 0, 0, 1],
[1, 1, 1, 1, 1],
]
start_x, start_y = 1, 2
target_color = 0
replacement_color = 2