A grid of colors is a graph in disguise: each cell is a node connected to its 4
neighbours (up, down, left, right — not diagonals).
solve(image, sr, sc, color) — starting at cell (sr, sc), recolor that cell
and every cell connected to it through cells of the same original color.
Return the new image; do not mutate the input.
Examples
solve([[1,1,1],[1,1,0],[1,0,1]], 1, 1, 2) → [[2,2,2],[2,2,0],[2,0,1]]
solve([[0,0,0],[0,0,0]], 0, 0, 0) → [[0,0,0],[0,0,0]] // already that color
solve([[1,2],[2,1]], 0, 0, 3) → [[3,2],[2,1]] // no diagonalsIf the new color equals the original one, return early — otherwise a naive
search never marks anything as visited and loops forever.
Sample tests