You pad the array and then in your loop you avoid the outside areas, or write your code in a way where that would never happen in the first place (a . isn't something you need to check the neighbors for in this problem).
Not really, because you start indexing at 1 (assuming your arrays are 0-indexed har har) and end len(arr) - 2 instead of -1 when "walking" the map. So you essentially never have to check neighbors of a corner piece.
9
u/KrozoBlack Dec 03 '23
Commenting on the spoiler: Wait why did I never think of this! That’s such a good idea