You are reading a single comment by @Greenbank and its replies.
Click here to read the full conversation.
-
Granted it's not absolutely necessary for day 1 but if you don't see the obvious optimisation then some of the later puzzles are going to be tough going.
Hint: You don't need a nested for loop for part 1 if you use the right data structure. You only need a single nested for loop (e.g. two for loops, not three) for part 2.
I did almost the exact same thing but with Pandas dataframes instead, now I've changed it to lists it runs in barely a second. If you only have a hammer...
I also looked into breaking from nested loops but it wasn't trivial so I decided not to bother. But reading again the highest voted answer to this question has a solution.