22 lines
486 B
Haskell
22 lines
486 B
Haskell
|
#!/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')
|