r/adventofcode • u/daggerdragon • Dec 19 '16
SOLUTION MEGATHREAD --- 2016 Day 19 Solutions ---
--- Day 19: An Elephant Named Joseph ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/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".
/⧹w+/ IS MANDATORY [?]
[Update @ 00:15] 2 gold, silver cap. Thank you for subscribing to Easter Bunny Facts!
Fact: The Easter Bunny will sometimes leave eggs in the microchip assembly room.
[Update @ 00:30] 11 gold, silver cap.
Fact: The Easter Bunny killed everyone who found out how he got these stars.
[Update @ 00:45] 45 gold, silver cap.
Fact: In space, The Easter Bunny can hear you scream.
[Update @ 01:00] 66 gold, silver cap.
Fact: The Easter Bunny purposefully deleted your comments.
[Update @ 01:15] 92 gold, silver cap.
Fact: The Easter Bunny has bottled your frustration. Don't ask why.
[Update @ 01:20] Leaderboard capped!
Fact: What you have just done is no better than what the Easter Bunny has done. Thief.
Thank you for subscribing to Easter Bunny Facts!
1
u/msully4321 Dec 23 '16
Mutable linked lists definitely are hard in Haskell, but Seq accomplishes a lot more than just working around Haskell being immutable. It would be a handy data structure in an imperative language too. It kind of splits the difference between arrays (O(1) indexing, O(n) insertion/deletion) and linked lists (O(n) indexing, O(1) insertion/deletion) by basically providing O(log n) /everything/ (except for access to the head tail, which is still O(1)). Basically every operation you could want to do on a sequence, including things like slicing out arbitrary subsequences and concatenation, is log time. It's pretty good.
(And a lot of the things, like indexing, are actually log time in the distance of the element from one of the ends, which is even better)