this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 30e1c9027434f4e1f89e5ca215d3f17b82a6c44b 21 lines 630 B view raw
1module Millisecond01 where 2 3import Data.Char 4 5processDigitStr :: String -> Int 6processDigitStr str = 7 let pairs = zip str (tail str ++ [head str]) 8 in sum . map (digitToInt . fst) . filter (uncurry (==)) $ pairs 9 10processDigitStr2 :: String -> Int 11processDigitStr2 str = 12 let halfStrLength = div (length str) 2 13 pairs = zip str ((drop halfStrLength str) ++ (take halfStrLength str)) 14 in sum . map (digitToInt . fst) . filter (uncurry (==)) $ pairs 15 16main :: IO () 17main = do 18 inputStr <- readFile "input.txt" 19 let input = init inputStr -- Drops the \n at the end 20 answer = processDigitStr2 input 21 in print answer