2018/Day5/Day5B.hs

22 lines
486 B
Haskell
Raw Normal View History

2018-12-05 13:14:47 +00:00
#!/usr/bin/env stack
-- stack --resolver lts-12.5 script
module Day5B where
import Day5A (calcLength)
import Data.Char
alphabet :: String
alphabet = "abcdefghijklmnopqrstuvwxyz"
caseNEq :: Char -> Char -> Bool
caseNEq x y = toLower x /= toLower y
mapper :: String -> Char -> Int
mapper s x = calcLength "" $ filter (caseNEq x) s
findShortest :: String -> Int
findShortest s = minimum $ map (mapper s) alphabet
main :: IO ()
main = interact $ show . findShortest . filter (/='\n')