From fe8fe811c25ac2b3dba1a440780fe6f82f574239 Mon Sep 17 00:00:00 2001 From: Amneesh Singh Date: Tue, 6 Dec 2022 11:20:07 +0530 Subject: [PATCH] day6: update - parser combinators have clouded my judgement Signed-off-by: Amneesh Singh --- day6.hs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/day6.hs b/day6.hs index 21207b5..cbf56f9 100644 --- a/day6.hs +++ b/day6.hs @@ -1,5 +1,4 @@ import Data.List (nub) -import Text.ParserCombinators.ReadP main :: IO () main = do @@ -9,7 +8,6 @@ main = do putStr "Q2: " print $ q2 input - q1, q2 :: String -> Int q1 = length . parse 4 q2 = length . parse 14 @@ -20,6 +18,4 @@ parse n a = parse' n (splitAt n a) parse' :: Int -> (String, String) -> String parse' n (a, b) | length (nub (drop (length a - n) a)) == n = a - | otherwise = - let (c, cs) = last $ readP_to_S get b - in parse' n (a ++ [c], cs) + | otherwise = parse' n (a ++ [head b], tail b)