I solved this one in Perl, it reminded me of trying to backtrack the camera positions of many photos (or lidar scans) of the same object, in order to generate a 3D model. As I put those in the queue, I also store the position of each beacon and scanner relative to the base scanner.Īfter all the hard work has been done, since I saved all beacons positions and scanner positions relative to the base, it's a simple count of the unique beacons positions across all scanners for part 1 and finding the maximum distance between each pair of scanners for part 2. ![]() Since Sn was queued with its orientation and position relative to the base scanner I can calculate Sk's orientation/position relative to the base scanner. ![]() Since the fingerprint has distances and vectors between all pairs of beacons, 12 beacons overlap when there are 66 or more identical fingerprint distances shared between 2 scanners.įor each overlapping scanner, Sk, calculate its position and orientation relative to Sn. When scanner Sn is popped off the queue, it neighbours are those undiscovered scanners with overlapping beacons. Each item added to queue has: scanner number, orientation (relative to base scanner), position (also relative to base scanner). ![]() It's basically the same idea as many others.Ī scanner struct with a fingerprint slot and a slot for its position relative to some arbitrary base scanner (initially empty).įingerprint is a hash to map distance squared -> two beacons and the vector between them - for all pairs of beacons in the scanner.Ī beacon struct with a position slot (as seen by the scanner) and a position as seen by the base scanner (initially empty).ĭo a BFS of scanners starting with any base scanner. I'm adding my Racket solutions to threads that are missing them since there are already a plethora of Python, Rust, Spreadsheet and IntCode solutions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |