part1 (3955B)
1--- Day 25: Four-Dimensional Adventure --- 2 3The reindeer's symptoms are getting worse, and neither you nor the white-bearded man have a 4solution. At least the reindeer has a warm place to rest: a small bed near where you're sitting. 5 6As you reach down, the reindeer looks up at you, accidentally bumping a button on your wrist-mounted 7device with its nose in the process - a button labeled [1m[97m"help"[0m. 8 9"Hello, and welcome to the Time Travel Support Hotline! If you are lost in time and space, press 1. 10If you are trapped in a time paradox, press 2. If you need help caring for a sick reindeer, press 3. 11If you--" 12 13[1m[97mBeep.[0m 14 15A few seconds later, you hear a new voice. "Hello; please state the nature of your reindeer." You 16try to describe the situation. 17 18"Just a moment, I think I can remotely run a diagnostic scan." A beam of light projects from the 19device and sweeps over the reindeer a few times. 20 21"Okay, it looks like your reindeer is very low on magical energy; it should fully recover if we can 22fix that. Let me check your timeline for a source.... Got one. There's actually a powerful source 23of magical energy about 1000 years forward from you, and at roughly your position, too! It looks 24like... hot chocolate? Anyway, you should be able to travel there to pick some up; just don't 25forget a mug! Is there anything else I can help you with today?" 26 27You explain that your device isn't capable of going forward in time. "I... see. That's tricky. 28Well, according to this information, your device should have the necessary hardware to open a small 29portal and send some hot chocolate back to you. You'll need a list of [1m[97mfixed points in spacetime[0m; I'm 30transmitting it to you now." 31 32"You just need to align your device to the constellations of fixed points so that it can lock on to 33the destination and open the portal. Let me look up how much hot chocolate that breed of reindeer 34needs." 35 36"It says here that your particular reindeer is-- this can't be right, it says there's only one like 37that in the universe! But THAT means that you're--" You disconnect the call. 38 39The list of fixed points in spacetime (your puzzle input) is a set of four-dimensional coordinates. 40To align your device, acquire the hot chocolate, and save the reindeer, you just need to find the 41[1m[97mnumber of constellations[0m of points in the list. 42 43Two points are in the same [1m[97mconstellation[0m if their manhattan distance apart is [1m[97mno more than 3[0m or if 44they can form a chain of points, each a manhattan distance no more than 3 from the last, between the 45two of them. (That is, if a point is close enough to a constellation, it "joins" that 46constellation.) For example: 47 48 0,0,0,0 49 3,0,0,0 50 0,3,0,0 51 0,0,3,0 52 0,0,0,3 53 0,0,0,6 54 9,0,0,0 5512,0,0,0 56 57In the above list, the first six points form a single constellation: 0,0,0,0 is exactly distance 3 58from the next four, and the point at 0,0,0,6 is connected to the others by being 3 away from 590,0,0,3, which is already in the constellation. The bottom two points, 9,0,0,0 and 12,0,0,0 are in a 60separate constellation because no point is close enough to connect them to the first constellation. 61So, in the above list, the number of constellations is [1m[97m2[0m. (If a point at 6,0,0,0 were present, it 62would connect 3,0,0,0 and 9,0,0,0, merging all of the points into a single giant constellation 63instead.) 64 65In this example, the number of constellations is 4: 66 67-1,2,2,0 680,0,2,-2 690,0,0,-2 70-1,2,0,0 71-2,-2,-2,2 723,0,2,-1 73-1,3,2,2 74-1,0,-1,0 750,2,1,-2 763,0,0,0 77 78In this one, it's 3: 79 801,-1,0,1 812,0,-1,0 823,2,-1,0 830,0,3,1 840,0,-1,-1 852,3,-2,0 86-2,2,0,0 872,-2,0,-1 881,-1,0,-1 893,2,0,2 90 91Finally, in this one, it's 8: 92 931,-1,-1,-2 94-2,-2,0,1 950,2,1,3 96-2,3,-2,1 970,2,3,-2 98-1,-1,1,-2 990,-2,-1,0 100-2,2,3,-1 1011,2,2,0 102-1,-2,0,-2 103 104The portly man nervously strokes his white beard. It's time to get that hot chocolate. 105 106[1m[97mHow many constellations are formed by the fixed points in spacetime?[0m 107 108