Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
eat up
Browse files Browse the repository at this point in the history
  • Loading branch information
mstksg committed Dec 13, 2023
1 parent bc96d2e commit 4972ce4
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/AOC/Challenge/Day12.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ where

import AOC.Prelude
import Data.Bitraversable
import Control.Monad.Writer
import qualified Data.Graph.Inductive as G
import qualified Data.IntMap as IM
import qualified Data.IntSet as IS
Expand All @@ -47,6 +48,7 @@ import qualified Text.Megaparsec.Char as P

-- #.#.### 1,1,3

-- | true = #, false = .
parseChar = \case
'#' -> Just $ Just True
'.' -> Just $ Just False
Expand Down Expand Up @@ -128,7 +130,7 @@ chunkUp = go
where
go = \case
[] -> []
Just False:xs -> chunkUp xs
Just False:xs -> go xs
Just True:xs -> eatUp (Seq.singleton True) xs
Nothing:xs -> eatUp (Seq.singleton False) xs
eatUp qs = \case
Expand Down Expand Up @@ -156,6 +158,19 @@ chunkPatterns = S.fromList . map reChunk . traverse (\case True -> [True]; False
-- -- [ _
-- -- ]

-- eatUp
-- :: [Bool]
-- -> [Seq Bool]
-- -> Int
-- eatUp = \case
-- [] -> \case
-- [] -> 1
-- _:_ -> 0
-- n:ns -> \case
-- [] -> 0
-- x:xs -> product do
-- n' <- eatUp


day12b :: _ :~> _
day12b =
Expand All @@ -169,7 +184,7 @@ day12b =
pat' = concat $ replicate 5 pat
xs' :: [Maybe Bool]
xs' = intercalate [Nothing] $ replicate 5 xs
in head $ chunkPatterns <$> chunkUp xs'
in chunkUp xs
-- in countTrue (matchesPat pat') $
-- expandOut . map (\qs -> (length qs, head qs)) $
-- group xs'
Expand Down

0 comments on commit 4972ce4

Please sign in to comment.