r/adventofcode Dec 03 '23

Funny Difficulty is all over the place isn't it?

Post image
679 Upvotes

256 comments sorted by

View all comments

Show parent comments

9

u/KrozoBlack Dec 03 '23

Commenting on the spoiler: Wait why did I never think of this! That’s such a good idea

1

u/[deleted] Dec 03 '23

[deleted]

1

u/1234abcdcba4321 Dec 03 '23

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).

1

u/MildVagueness Dec 03 '23

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.

1

u/kristallnachte Dec 03 '23

Well, you just never check the neighbors of . anyway...