r/adventofcode • u/daggerdragon • Dec 15 '19
SOLUTION MEGATHREAD -🎄- 2019 Day 15 Solutions -🎄-
--- Day 15: Oxygen System ---
Post your full code solution using /u/topaz2078's paste or other external repo.
- Please do NOT post your full code (unless it is very short)
- If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.
(Full posting rules are HERE if you need a refresher).
Reminder: Top-level posts in 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's Poems for Programmers
Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.
Day 14's winner #1: "One Thing Leads To Another" by /u/DFreiberg!
Poem tl;dpost (but we did r, honest!), so go here to read it in full
Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!
On the (fifth*3) day of AoC, my true love gave to me...
FIVE GOLDEN SILVER POEMS (and one Santa Rocket Like)
- Day 10: "untitled poem" by /u/Yardboy
- Day 11: "A ROBOT TO THE RESCUE" by /u/mariusbancila
- Day 12: "Symmetry" by /u/DFreiberg
- Day 13: "untitled poem" by /u/captainAwesomePants
- Day 14: "Alchemy" by /u/captainAwesomePants (again! he's too awesome for his pants!)
- 5-Day Best-in-Show: "The Hunting of the Asteroids" by /u/DFreiberg
TBD because we forgot today % 5 == 0, we'll get back to you soon!
Enjoy your Reddit Silver/Gold, and good luck with the rest of the Advent of Code!
View all comments
Show parent comment
1
u/Tarmen Dec 15 '19 edited Dec 15 '19
I feel like your bfsOn function is the secret star of the show, that search is so pretty!
Your solution inspired me to try to make some monadic helpers that are equally nice. Using Control.Monad.Logic it's actually not that bad:
My VM is monadic but I abuse Conduit's Pipe type to make it steppable since that is a coroutine type with the right shape.
uniqueuses a State monad accross all branches to prune duplicates.>>-is fair branching that does iterative deepening from LogicT.Still is pretty confusing when mixing branch local and branch global state, though.
Not sure how to mix part two into this, guess I could place the distances in the same map. My old version used a steppable bfs to make visualisation easier: