-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmars.hs
More file actions
24 lines (21 loc) · 682 Bytes
/
mars.hs
File metadata and controls
24 lines (21 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Data.Functor
import Control.Monad.Writer
import Control.Monad
import Data.Monoid
solve :: String -> Integer
solve s = getSum $ snd $ (runWriter inner_solve)
where
ideal = take (length s) $ concat $ repeat "SOS"
inner_solve :: Writer (Sum Integer) ()
inner_solve =
mapM_ (\(l, r) ->
if l /= r
then
do
tell 1
return ()
else
return ()) (zip s ideal)
main = do
s <- getLine
putStrLn $ show $ solve s