Please don’t rely on this Gitea instance being around forever. If any of your build scripts use my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking for there, tell me to migrate it.
day7backup
Arranun 3 years ago
parent 7b8e8914c4
commit f0e8c8488d

@ -0,0 +1,29 @@
import Data.List as List
import Data.Char as Char
main = do
putStrLn("Hello")
issorted :: [Int] -> Bool
issorted xs = and $ zipWith(<=) xs (tail xs)
digits :: Int -> [Int]
digits = map Char.digitToInt . show
hasAdjacentPair :: [Int] -> Bool
hasAdjacentPair n = (maximum (map length (List.group n))) >= 2
hasAdjacentPairb :: [Int] -> Bool
hasAdjacentPairb n = elem 2 (map length (List.group n))
day4a :: Int -> Bool
day4a n =(hasAdjacentPair $ digits n) && ( issorted $ digits n )
day4b :: Int -> Bool
day4b n =(hasAdjacentPairb $ digits n) && ( issorted $ digits n )
filterDay4a :: [Int] -> [Int]
filterDay4a ns = filter(\n-> day4a n) ns
filterDay4b :: [Int] -> [Int]
filterDay4b ns = filter(\n-> day4b n) ns
Loading…
Cancel
Save