Created
December 2, 2020 22:11
-
-
Save mjgpy3/efe0ca57d60c279ea8e1d1c461fd40ff to your computer and use it in GitHub Desktop.
aoc-2019-d4p2.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module D4 where | |
| import Control.Monad (guard) | |
| import Data.List (group) | |
| s = 147981 | |
| e = 691423 | |
| exTwoAdj = elem 2 . map length . group . show | |
| notDecr = go . show | |
| where | |
| go (x:y:rest) = x <= y && go (y:rest) | |
| go [x] = True | |
| go _ = False | |
| possible = do | |
| v <- [s..e] | |
| guard $ exTwoAdj v && notDecr v | |
| pure v | |
| main = print $ length possible |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment