From: Neil Smith Date: Sat, 10 Dec 2022 17:20:09 +0000 (+0200) Subject: Done day 9 part 1 X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=cf504bf2ef588403a211f64e7ae0e144f2a72b31;p=advent-of-code-22.git Done day 9 part 1 --- diff --git a/advent-of-code22.cabal b/advent-of-code22.cabal index 0f7e6b5..1e73cd1 100644 --- a/advent-of-code22.cabal +++ b/advent-of-code22.cabal @@ -140,4 +140,8 @@ executable advent07 executable advent08 import: common-extensions, build-directives main-is: advent08/Main.hs - -- build-depends: text, attoparsec, containers, path-tree, rosezipper + +executable advent09 + import: common-extensions, build-directives + main-is: advent09/Main.hs + build-depends: text, attoparsec, containers, linear, lens diff --git a/advent09/Main.hs b/advent09/Main.hs new file mode 100644 index 0000000..0f7714d --- /dev/null +++ b/advent09/Main.hs @@ -0,0 +1,90 @@ +-- Writeup at https://work.njae.me.uk/2022/12/04/advent-of-code-2022-day-4/ + +import AoC +import Data.Text (Text) +import qualified Data.Text.IO as TIO +import Data.Attoparsec.Text hiding (take, D) +import Control.Applicative +import Data.List +import qualified Data.Set as S +import Linear hiding (Trace, trace, distance) +import Control.Lens + +type Position = V2 Int +type Trace = S.Set Position +type Path = [Position] + +data Rope = Rope + { _headR :: Position + , _tailR :: Position + , _trace :: Trace + } deriving (Show, Eq) +makeLenses ''Rope + +data Direction = U Int | R Int | D Int | L Int + deriving (Show, Eq, Ord) + +main :: IO () +main = + do dataFileName <- getDataFileName + text <- TIO.readFile dataFileName + let path = successfulParse text + let steps = expandPath path + print $ part1 steps + +part1 :: Path -> Int +part1 steps = S.size $ rope' ^. trace + where rope' = ropeSteps newRope steps + +expandPath :: [Direction] -> Path +expandPath = concatMap expandStep + where expandStep (U n) = replicate n (V2 0 1) + expandStep (L n) = replicate n (V2 -1 0) + expandStep (D n) = replicate n (V2 0 -1) + expandStep (R n) = replicate n (V2 1 0) + + +manhattan :: Position -> Position -> Int +manhattan p1 p2 = max dx dy + where V2 dx dy = abs $ p1 ^-^ p2 + +touching :: Position -> Position -> Bool +touching p1 p2 = (manhattan p1 p2) <= 1 + +towards :: Position -> Position -> Position +towards p1 p2 = signum $ p2 ^-^ p1 + +newRope :: Rope +newRope = Rope { _headR = V2 0 0, _tailR = V2 0 0, _trace = S.singleton (V2 0 0) } + +ropeSteps :: Rope -> Path -> Rope +ropeSteps rope steps = foldl' ropeStep rope steps + +ropeStep :: Rope -> Position -> Rope +ropeStep rope step = rope & headR .~ hr + & tailR .~ tailR' + & trace %~ S.insert tailR' + where hr = (rope ^. headR) ^+^ step + tr = rope ^. tailR + tailR' = if tr `touching` hr + then rope ^. tailR + else tr ^+^ (tr `towards` hr) + +-- Parse the input file + +pathP :: Parser [Direction] +directionP, upP, leftP, downP, rightP :: Parser Direction + +pathP = directionP `sepBy` endOfLine +directionP = upP <|> leftP <|> downP <|> rightP +upP = U <$> ("U " *> decimal) +leftP = L <$> ("L " *> decimal) +downP = D <$> ("D " *> decimal) +rightP = R <$> ("R " *> decimal) + + +successfulParse :: Text -> [Direction] +successfulParse input = + case parseOnly pathP input of + Left _err -> [] -- TIO.putStr $ T.pack $ parseErrorPretty err + Right path -> path diff --git a/data/advent09.txt b/data/advent09.txt new file mode 100644 index 0000000..31b7fd1 --- /dev/null +++ b/data/advent09.txt @@ -0,0 +1,2000 @@ +R 2 +D 2 +U 2 +D 1 +L 1 +D 2 +R 2 +L 2 +R 1 +D 2 +L 1 +U 2 +R 1 +D 1 +R 1 +L 1 +D 1 +R 2 +U 2 +L 2 +R 2 +U 2 +R 1 +L 1 +D 2 +R 1 +D 1 +R 1 +D 1 +R 1 +L 2 +R 1 +D 1 +L 1 +U 2 +L 1 +D 1 +L 1 +R 1 +U 2 +D 1 +U 2 +L 2 +R 2 +D 1 +L 1 +R 1 +D 1 +L 1 +U 1 +R 2 +D 1 +R 1 +D 2 +L 1 +D 2 +L 1 +D 2 +R 1 +L 1 +D 2 +L 1 +R 1 +D 2 +L 2 +R 2 +L 1 +U 2 +R 1 +U 2 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R 13 +L 13 +R 11 +L 16 +D 10 +L 6 +R 3 +D 8 +L 19 +U 18 +L 14 +D 15 +U 10 +D 11 +R 19 +D 14 +U 2 +R 7 +U 6 +D 15 +U 10 +D 4 +U 10 +L 9 +R 15 +L 8 +U 7 +R 4 +D 5 +R 18 +L 3 +R 11 +D 11 +R 2 +U 1 +L 6 +D 18 +R 15 +U 2 +R 10 +L 18 +R 1 +U 19 +D 15 +R 18 +L 18 +R 4 +L 7 +D 18 +R 19 +U 11 +D 3 +L 3 +R 11 +U 16 +R 3 +D 4 +U 2 +R 10 +U 9 +L 18 +U 6 +L 5 +D 7 +L 17 +U 3 +L 5 +D 6 +U 19 +R 14 +U 3 +D 1 +U 16 +L 16 +D 12 +L 11 +D 16 +R 15 +U 5 +D 14 +L 3 +U 18 +L 8 +U 10 +L 10 +D 10 +R 5 \ No newline at end of file diff --git a/data/advent09a.txt b/data/advent09a.txt new file mode 100644 index 0000000..cbea2b3 --- /dev/null +++ b/data/advent09a.txt @@ -0,0 +1,8 @@ +R 4 +U 4 +L 3 +D 1 +R 4 +D 1 +L 5 +R 2 \ No newline at end of file