From 3ad0f674265f18dc390d3d6078348cea5f36f98c Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Tue, 27 Dec 2022 08:34:39 +0000 Subject: [PATCH] Tidying --- advent17/Main.hs | 1 - advent19/Main.hs | 4 ++-- advent20/Main.hs | 4 ++-- advent21/Main.hs | 2 +- advent22/Main.hs | 8 ++++++-- advent25/Main.hs | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/advent17/Main.hs b/advent17/Main.hs index 57794a9..ce3ad42 100644 --- a/advent17/Main.hs +++ b/advent17/Main.hs @@ -4,7 +4,6 @@ import AoC import qualified Data.Set as S -import qualified Data.Map.Strict as M import Linear hiding (Trace, trace, distance) import Control.Lens import Data.Maybe diff --git a/advent19/Main.hs b/advent19/Main.hs index b5cd5c4..7fe0315 100644 --- a/advent19/Main.hs +++ b/advent19/Main.hs @@ -1,6 +1,6 @@ -- Writeup at https://work.njae.me.uk/2022/12/21/advent-of-code-2022-day-19/ -import Debug.Trace +-- import Debug.Trace import AoC import Data.Text (Text) @@ -16,7 +16,7 @@ import Data.MultiSet as MS import Data.Sequence ((|>)) import Data.List import Data.Maybe -import Data.Ord +-- import Data.Ord import Control.Monad.Reader import Control.Lens hiding ((<|), (|>), (:>), (:<), indices) import Control.Parallel.Strategies diff --git a/advent20/Main.hs b/advent20/Main.hs index eb60a15..355d949 100644 --- a/advent20/Main.hs +++ b/advent20/Main.hs @@ -1,10 +1,10 @@ -- Writeup at https://work.njae.me.uk/2022/12/21/advent-of-code-2022-day-20/ import AoC -import Data.List +import Data.List hiding (elemIndex) import Data.Maybe import Data.CircularList -import Control.Lens +import Control.Lens hiding (element) data IndexedElem = IndexedElem { _idx :: Int, _shift :: Int, _value :: Int} deriving (Show, Eq, Ord) diff --git a/advent21/Main.hs b/advent21/Main.hs index 1811612..6d856e5 100644 --- a/advent21/Main.hs +++ b/advent21/Main.hs @@ -7,7 +7,7 @@ import Data.Attoparsec.Text hiding (take, D) import Control.Applicative import qualified Data.Map.Strict as M import Data.Map.Strict ((!)) -import Control.Lens +import Control.Lens hiding (op) data Shout = Literal Int | Operation Operator String String deriving (Show, Eq, Ord) diff --git a/advent22/Main.hs b/advent22/Main.hs index 1a2e1c7..848be83 100644 --- a/advent22/Main.hs +++ b/advent22/Main.hs @@ -2,6 +2,7 @@ -- import Debug.Trace + import AoC import Prelude hiding (Left, Right) import qualified Data.Map.Strict as M @@ -253,13 +254,16 @@ isCell r c rows = isRow && isCol && ((rows !! r) !! c) `elem` (".#" :: String) where isRow = r < length rows isCol = c < (length $ rows !! r) -mkInstructions :: String -> [PathElement] +mkInstructions, mkWalk, mkTurn :: String -> [PathElement] mkInstructions [] = [] -mkInstructions text@(t:ts) +mkInstructions text@(t:_) | isDigit t = mkWalk text | otherwise = mkTurn text + mkWalk text = (Forward $ read digits) : (mkInstructions remainder) where (digits, remainder) = span (isDigit) text + +mkTurn [] = [] mkTurn (t:ts) | t == 'R' = Clockwise : (mkInstructions ts) | t == 'L' = Anticlockwise : (mkInstructions ts) diff --git a/advent25/Main.hs b/advent25/Main.hs index 28c33f7..c58c47d 100644 --- a/advent25/Main.hs +++ b/advent25/Main.hs @@ -35,7 +35,7 @@ packSnafu :: [Int] -> String packSnafu digits | carry == 0 = shown | otherwise = (snafuRep carry) : shown - where (carry, shown) = foldl' packSnafuDigit (0, "") + where (carry, shown) = foldl' packSnafuDigit (0, "") digits packSnafuDigit :: (Int, String) -> Int -> (Int, String) packSnafuDigit (carry, acc) d -- 2.34.1