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
{-# 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)
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