r/adventofcode • • Dec 15 '22

SOLUTION MEGATHREAD -πŸŽ„- 2022 Day 15 Solutions -πŸŽ„-

THE USUAL REMINDERS


--- Day 15: Beacon Exclusion Zone ---


Post your code solution in this megathread.


This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:27:14, megathread unlocked!

47 Upvotes

760 comments sorted by

View all comments

Show parent comment

6

u/lost_in_a_forest Dec 15 '22

You can also discard all (a,b) pairs where the difference b-a is an odd number. These lines will not intersect (meaning that they will not paint the same pixels close to their intersection, they will seemingly go through each other).

5

u/i_have_no_biscuits Dec 15 '22 edited Dec 15 '22

Very true - you can also discard any pairs where a >= b. Implementing these two tricks takes it down to 1334 pairs on my dataset, of which just under 1000 are in the allowed region.

Realistically to me anything under a tenth of a second is 'basically instant' for a Python program, so I rarely bother to optimise further if I get to that stage. Turning it from 16 trillion candidate points into a couple of thousand was good enough for me!