--- Writeup at https://work.njae.me.uk/2021/12/13/advent-of-code-2021-day-13/
+-- Writeup at https://work.njae.me.uk/2021/12/16/advent-of-code-2021-day-14/
import Data.Text ()
import qualified Data.Text.IO as TIO
where a = pair!!1
c = rules ! pair
--- countElements :: PolyPairs -> MS.MultiSet Char
countElements :: PolyPairs -> M.Map Char Int
countElements pairs = counts
where firsts = MS.map (!!0) pairs
seconds = MS.map (!!1) pairs
elems = S.union (MS.toSet firsts) (MS.toSet seconds)
- -- counts = MS.fromMap $ M.map ((`div` 2) . (+ 1)) $ MS.toMap $ MS.union firsts seconds
counts = M.map ((`div` 2) . (+ 1)) $ MS.toMap $ MS.union firsts seconds
--- Writeup at https://work.njae.me.uk/2021/12/13/advent-of-code-2021-day-13/
-
+-- Writeup at https://work.njae.me.uk/2021/12/16/advent-of-code-2021-day-15/
import Debug.Trace
-- import qualified Data.Text.IO as TIO
--- import qualified Data.Map.Strict as M
--- import Data.Map.Strict ((!))
import qualified Data.PQueue.Prio.Min as P
import qualified Data.Set as S
import qualified Data.Sequence as Q
import Data.Maybe (fromMaybe)
import Linear (V2(..), (^+^), (^-^), (*^), (^*))
import Data.Array.IArray
--- import Data.List
-
pattern Empty <- (Q.viewl -> Q.EmptyL) where Empty = Q.empty
pattern x :< xs <- (Q.viewl -> x Q.:< xs) where (:<) = (Q.<|)
--- Writeup at https://work.njae.me.uk/2021/12/13/advent-of-code-2021-day-13/
-
+-- Writeup at https://work.njae.me.uk/2021/12/16/advent-of-code-2021-day-15/
import Debug.Trace
--- import qualified Data.Text.IO as TIO
-
--- import qualified Data.Map.Strict as M
--- import Data.Map.Strict ((!))
import qualified Data.PQueue.Prio.Min as P
import qualified Data.Set as S
import qualified Data.Sequence as Q
import Data.Maybe (fromMaybe)
import Linear (V2(..), (^+^), (^-^), (*^), (^*))
import Data.Array.IArray
--- import Data.List
-
pattern Empty <- (Q.viewl -> Q.EmptyL) where Empty = Q.empty
pattern x :< xs <- (Q.viewl -> x Q.:< xs) where (:<) = (Q.<|)
, _trail = newTrail
, _cost = incurred + predicted
}
--- makeAgendum :: SearchState s => (Q.Seq s) -> Int -> s -> CaveContext (Agendum s)
--- makeAgendum previous prevCost newPosition =
--- do predicted <- estimateCost newPosition
--- grid <- asks _grid
--- let newTrail = previous |> newPosition
--- newPositionCost <- entryCost newPosition
--- let incurred = prevCost + newPositionCost
--- return Agendum { _current = newPosition
--- , _trail = newTrail
--- , _cost = incurred + predicted
--- }
---
\ No newline at end of file