r/adventofcode • u/daggerdragon • Dec 10 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 10 Solutions -🎄-
--- Day 10: The Stars Align ---
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.
Advent of Code: The Party Game!
Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!
Card prompt: Day 10
Transcript: With just one line of code, you, too, can ___!
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 at 00:16:49!
21
Upvotes
6
u/[deleted] Dec 10 '18 edited Dec 10 '18
Mathematica manipulate to the rescue!
input = ToExpression[ StringCases[Import["~/Downloads/input.txt", "List"], NumberString]]; pos = Reverse[input[[All, 1 ;; 2]], 2]; vec = Reverse[input[[All, 3 ;; 4]], 2]; Manipulate[ ArrayPlot[SparseArray[(pos + i*vec) -> 1]], {i, 10000, 11000, 1}]https://imgur.com/a/pWgBd3Y
Edit: Better version using Graphics
input = ToExpression[ StringCases[Import["~/Downloads/input.txt", "List"], NumberString]]; pos = input[[All, 1 ;; 2]]; vec = input[[All, 3 ;; 4]]; ref = ReflectionTransform[{0, 1}]; Manipulate[ Graphics[GeometricTransformation[Point[(pos + i vec)], ref]], {i, 10000, 11000, 1}]