From fe8c4a3ad87b742b653ec34534497a6042b0831b Mon Sep 17 00:00:00 2001 From: Chelsey Lee <49125778+chelsey0527@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:50:53 -0700 Subject: [PATCH] Update flood fill.py with assert statements --- flood fill.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flood fill.py b/flood fill.py index de93cc1..6dcdb1d 100644 --- a/flood fill.py +++ b/flood fill.py @@ -5,6 +5,11 @@ def fill(x, y): # You can combine the two if statements below into one, but I think it's easier to read this way. if x < 0 or x >= len(input_board) or y < 0 or y >= len(input_board[0]) or input_board[x][y] != old: return + + # Check if x and y are within valid coordinates + if x >= len(input_board) or y >= len(input_board[0]): + return input_board # Return the board unchanged + # if x < 0 or x >= len(input_board) or y < 0 or y >= len(input_board[0]): # return # if input_board[x][y] != old: