19 lines
499 B
Haskell
Executable File
19 lines
499 B
Haskell
Executable File
#! /usr/bin/env stack
|
|
-- stack --resolver lts-12.20 --install-ghc script
|
|
{-# LANGUAGE ViewPatterns #-}
|
|
module Main where
|
|
|
|
import qualified Data.Char as C
|
|
import qualified Data.List as L
|
|
|
|
main :: IO ()
|
|
main = interact $ show . length . react . takeWhile C.isAlpha
|
|
|
|
react [] = []
|
|
react (x:(react -> ys))
|
|
| (y:ys') <- ys, x `reactsWith` y = ys'
|
|
| otherwise = x:ys
|
|
|
|
x `reactsWith` y = (C.isUpper x && C.toLower x == y) ||
|
|
(C.isLower x && C.toUpper x == y)
|