Faster day 14, with mutable unboxed arrays
[advent-of-code-23.git] / advent12 / MainBruteForce.hs
index 9aa9ae3914320522e9bfc2a087dea28c743fc2fe..7d11334d9c38ea378d8ffb4589ea7b2f7dd5b48b 100644 (file)
@@ -1,4 +1,4 @@
--- Writeup at https://work.njae.me.uk/2023/12/08/advent-of-code-2023-day-8/
+-- Writeup at https://work.njae.me.uk/2023/12/15/advent-of-code-2023-day-12/
 
 import AoC
 import Data.Text (Text)
@@ -49,9 +49,6 @@ choose n (x:xs)
   | length xs == n - 1 = [(x:xs)]
   | otherwise = (fmap (x:) (choose (n-1) xs)) ++ (choose n xs)
 
--- unknownIndices :: [Spring] -> [Int]
--- unknownIndices = elemIndices Unknown
-
 numDamagedToPlace :: Record -> Int
 numDamagedToPlace (Record springs signature) = totalDamaged - knownDamaged
   where knownDamaged = length $ filter (== Damaged) springs
@@ -81,7 +78,7 @@ recordP :: Parser Record
 springP :: Parser Spring
 
 recordsP = recordP `sepBy` endOfLine
-recordP = Record <$> (many1 springP <* " ") <*> (decimal `sepBy` ",")
+recordP = Record <$> many1 springP <* " " <*> decimal `sepBy` ","
 springP = (Unknown <$ "?") <|> (Damaged <$ "#") <|> (Operational <$ ".")
 
 successfulParse :: Text -> [Record]