{-# Language QuasiQuotes #-}
module Main (main) where
import Advent.Format (format)
import Data.List (intersect, union)
main :: IO ()
IO ()
main =
do [[[Char]]]
inp <- [format|2020 6 (%s%n)*&%n|]
Int -> IO ()
forall a. Show a => a -> IO ()
print ([Char] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (([Char] -> [Char] -> [Char]) -> [Char] -> [[Char]] -> [Char]
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr [Char] -> [Char] -> [Char]
forall a. Eq a => [a] -> [a] -> [a]
union [] ([[Char]] -> [Char]) -> [[[Char]]] -> [Char]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [[[Char]]]
inp))
Int -> IO ()
forall a. Show a => a -> IO ()
print ([Char] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (([Char] -> [Char] -> [Char]) -> [[Char]] -> [Char]
forall a. (a -> a -> a) -> [a] -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 [Char] -> [Char] -> [Char]
forall a. Eq a => [a] -> [a] -> [a]
intersect ([[Char]] -> [Char]) -> [[[Char]]] -> [Char]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [[[Char]]]
inp))