Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.List as L
- import Data.Sequence as Q
- data Bird = Azure | Black | Carmine
- main = interact $ unlines . map (show . Q.length) . L.filter onlyAzure .
- L.unfoldr bellRing . flip Q.replicate Azure . read
- bellRing Empty = Nothing
- bellRing w@(first :<| w') = Just (w,w''') where
- w''' = case w' of _ :<| w'' -> w'' >< endOfLine
- Empty -> empty -- I HATE YOU STUPID EDGE CASE
- endOfLine = case first of Azure -> fromList [Black,Carmine]
- Black -> singleton Azure
- Carmine -> Q.replicate 3 Azure
- onlyAzure w | Azure :<| _ <- w, _ :|> Azure <- w = True
- onlyAzure _ = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement