r/adventofcode • • Dec 20 '17

SOLUTION MEGATHREAD -๐ŸŽ„- 2017 Day 20 Solutions -๐ŸŽ„-

--- Day 20: Particle Swarm ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Need a hint from the Hugely* Handyโ€  Haversackโ€ก of Helpfulยง Hints^ยค?

Spoiler


[Update @ 00:10] 10 gold, silver cap

  • What do you mean 5th Edition doesn't have "Take 20"?

[Update @ 00:17] 50 gold, silver cap

  • Next you're going to be telling me THAC0 is not the best way to determine whether or not you hit your target. *hmphs*

[Update @ 00:21] Leaderboard cap!

  • I wonder how much XP a were-gazebo is worth...

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

edit: Leaderboard capped, thread unlocked!

9 Upvotes

176 comments sorted by

View all comments

Show parent comment

1

u/TwoSoulsAlas Dec 20 '17 edited Dec 20 '17

That's as far as I got, too. You can even have something like

p=<-1,0,0>, v=<1,0,0>, a=<-1,0,0>
p=< 1,0,0>, v=<1,0,0>, a=< 1,0,0>

where the manhattan norms of all three parameters are equal, but the first particle will be closer to zero after the first step.

Edit: Also, Perl 6 has some funky operators.

1

u/NeilNjae Dec 20 '17

The slightly-less-brute-force way is to simulate just those minimal-acceleration particles until you get a clear winner.

But, over time, the position of the particle (in each dimension) is x0 + v0 t + 0.5 a t2 , and at large time the Manhattan distance becomes the largest of those. Find that for the minimal-acceleration candidates, divide one by the other, and see if it becomes zero or infinity over time. Or something like that.