Finished day 6
This commit is contained in:
parent
b344686716
commit
97f5bd536f
1 changed files with 9 additions and 6 deletions
15
day6/main.hs
15
day6/main.hs
|
@ -43,11 +43,13 @@ paragraphs strs = go (strs, [])
|
|||
solvePart1 :: [String] -> Int
|
||||
solvePart1 = sum . (map countUniqueAnswers) . paragraphs
|
||||
|
||||
allAnsweredX :: Char -> [[String]] -> Bool
|
||||
allAnsweredX c = all (any (== c))
|
||||
allAnsweredX :: Char -> [[String]] -> [Bool]
|
||||
allAnsweredX c = map (all (any (== c)))
|
||||
|
||||
solvePart2 :: [String] -> [Bool]
|
||||
solvePart2 = allAnsweredX 'a' . paragraphs
|
||||
|
||||
|
||||
solvePart2 :: [String] -> Int
|
||||
solvePart2 strs = length . (filter (== True)) $ concat $ map (\x -> (allAnsweredX x . paragraphs) strs) ['a'..'z']
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
@ -63,7 +65,8 @@ main = do
|
|||
input <- lines <$> readFile "day6/input"
|
||||
print $ solvePart1 input
|
||||
putStrLn "Day 6 - Part 2 : solving test"
|
||||
print $ paragraphs exampleData
|
||||
print $ solvePart2 exampleData
|
||||
-- putStrLn "Day 6 - Part 2 : solving input"
|
||||
-- print $ solvePart2 input
|
||||
putStrLn "Day 6 - Part 2 : solving input"
|
||||
print $ solvePart2 input
|
||||
|
||||
|
|
Loading…
Reference in a new issue