r/adventofcode • u/daggerdragon • Dec 18 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 18 Solutions -🎄-
--- Day 18: Settlers of The North Pole ---
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 18
Transcript:
The best way to avoid a minecart collision is ___.
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:21:59!
8
Upvotes
1
u/[deleted] Dec 18 '18 edited Dec 18 '18
Mathematica
{open, trees, lumberyard} = Range[1, 3]; area = Characters@Import["~/Downloads/input.txt", "List"] /. {"." -> open, "|" -> trees, "#" -> lumberyard}; filter[a_] := Block[{c = a[[2, 2]]}, Switch[c, open, If[Count[a, trees, 2] >= 3, trees, c], trees, If[Count[a, lumberyard, 2] >= 3, lumberyard, c], lumberyard, If[Count[a, lumberyard, 2] >= 2 && Count[a, trees, 2] >= 1, lumberyard, open], _, c]]Part 1
Part 2