From 7d0dcf303453a2dceb73f165c6a6004b53c6d966 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sun, 16 Dec 2018 16:11:15 +0000 Subject: [PATCH] Tidying day 13 --- advent-of-code.cabal | 9 ++++++++- src/advent13/advent13.hs | 8 +------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/advent-of-code.cabal b/advent-of-code.cabal index d45d830..f7c1757 100644 --- a/advent-of-code.cabal +++ b/advent-of-code.cabal @@ -174,4 +174,11 @@ executable advent13 main-is: advent13.hs default-language: Haskell2010 build-depends: base >= 4.7 && < 5 - , containers \ No newline at end of file + , containers + +executable advent14 + hs-source-dirs: src/advent14 + main-is: advent14.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5 + , containers \ No newline at end of file diff --git a/src/advent13/advent13.hs b/src/advent13/advent13.hs index c1bf4d8..7e5c7f3 100644 --- a/src/advent13/advent13.hs +++ b/src/advent13/advent13.hs @@ -1,13 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} - import Prelude hiding (Left, Right) import Data.List import Data.Tuple (swap) import qualified Data.Map.Strict as M import Data.Map.Strict ((!)) -import Debug.Trace +-- import Debug.Trace type Coord = (Int, Int) -- x, y data Cell = Horizontal | Vertical | TopLeft | TopRight | Junction deriving (Show, Eq) @@ -17,18 +16,13 @@ data Cart = Cart Direction Decision deriving (Eq, Show) type Layout = M.Map Coord Cell type Carts = M.Map Coord Cart - main :: IO () main = do text <- readFile "data/advent13.txt" let (layout, carts) = parse text - -- print carts - -- print layout - -- print $ propogateUntilCollision (orderedCarts carts) layout carts putStrLn $ showCoord $ part1 carts layout putStrLn $ showCoord $ part2 carts layout - part1 :: Carts -> Layout -> Coord part1 carts layout = collisionSite where (collisionSite, _, _, _) = propogateUntilCollision (orderedCarts carts) layout carts -- 2.34.1