X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent13%2FMain.hs;h=89aecf43d6a15961c70fc200af1e1735d6de1b5f;hb=86f61207669563aa3134ec14d52555b12bd7860c;hp=69afc492d84825aba2127a7481862a0b3434990d;hpb=d7d6a1ba093b4ae8535bcd72bfca94be5b66ec7a;p=advent-of-code-21.git diff --git a/advent13/Main.hs b/advent13/Main.hs index 69afc49..89aecf4 100644 --- a/advent13/Main.hs +++ b/advent13/Main.hs @@ -1,5 +1,4 @@ --- Writeup at https://work.njae.me.uk/2021/12/09/advent-of-code-2021-day-8/ - +-- Writeup at https://work.njae.me.uk/2021/12/13/advent-of-code-2021-day-13/ import Data.Text () import qualified Data.Text.IO as TIO @@ -22,8 +21,6 @@ data Axis = X | Y data Fold = Fold Axis Int deriving (Eq, Ord, Show) - - main :: IO () main = do text <- TIO.readFile "data/advent13.txt" @@ -66,9 +63,9 @@ showSheet sheet = unlines [ concat [showPoint (V2 x y) | x <- ([0..maxX] :: [Int -- Parse the input file -inputP = (,) <$> sheetP <* (many1 endOfLine) <*> foldsP +inputP = (,) <$> sheetP <* many1 endOfLine <*> foldsP -sheetP = S.fromList <$> (dotP `sepBy` endOfLine) +sheetP = S.fromList <$> dotP `sepBy` endOfLine dotP = V2 <$> decimal <* "," <*> decimal foldsP = foldP `sepBy` endOfLine