From c42805c934d8b0300b8c4d9ba10b1162585b31b7 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Thu, 16 Dec 2021 17:48:32 +0000 Subject: [PATCH] Added links to blog posts --- advent14/Main.hs | 4 +--- advent15/Main.hs | 7 +------ advent15/MainSlow.hs | 21 +-------------------- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/advent14/Main.hs b/advent14/Main.hs index c6ade97..436f3d2 100644 --- a/advent14/Main.hs +++ b/advent14/Main.hs @@ -1,4 +1,4 @@ --- 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 @@ -60,13 +60,11 @@ addSecond rules pair = c ++ [a] 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 diff --git a/advent15/Main.hs b/advent15/Main.hs index 227f160..758bdc6 100644 --- a/advent15/Main.hs +++ b/advent15/Main.hs @@ -1,12 +1,9 @@ --- 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 @@ -18,8 +15,6 @@ import Control.Lens hiding ((<|), (|>), (:>), (:<)) 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.<|) diff --git a/advent15/MainSlow.hs b/advent15/MainSlow.hs index 3a77a02..17fe1b6 100644 --- a/advent15/MainSlow.hs +++ b/advent15/MainSlow.hs @@ -1,12 +1,7 @@ --- 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 @@ -18,8 +13,6 @@ import Control.Lens hiding ((<|), (|>), (:>), (:<)) 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.<|) @@ -217,15 +210,3 @@ makeAgendum previous newPosition = , _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 -- 2.34.1