Changing my approach from sides to corners really allowed me to solve part 2. Thanks for that! For part 1, I made it so that each node started at perimeter value 4 and decremented one for each neighbor. I maintained the same logic for part two with an added verification after visiting all the nodes. If the node had 1 neighbor, then it had 2 corners. Else if the node had 0 neighbors, it had 4 corners. Else, based on the position of neighbors I incremented the corner count starting from zero. Very verbose but got the job done. I hope to see how you finished your implementation.
Changing my approach from sides to corners really allowed me to solve part 2. Thanks for that!
For part 1, I made it so that each node started at perimeter value 4 and decremented one for each neighbor.
I maintained the same logic for part two with an added verification after visiting all the nodes. If the node had 1 neighbor, then it had 2 corners. Else if the node had 0 neighbors, it had 4 corners. Else, based on the position of neighbors I incremented the corner count starting from zero. Very verbose but got the job done.
I hope to see how you finished your implementation.
I do these challenges and then come and see how you did it. I never considered counting corners.