git.haldean.org aoc-2018 / 8c13451 05 / Aoc05.hs
8c13451

Tree @8c13451 (Download .tar.gz)

Aoc05.hs @8c13451raw · history · blame

1
2
3
4
5
6
7
8
import Control.Arrow
import Data.Char
import Data.Function

collapse1 (a:b:ss) = if toLower a == toLower b && a /= b then collapse1 ss else a:(collapse1 $ b:ss)
collapse1 s = s
collapse s = let cs = collapse1 s in if cs == s then s else collapse cs
main = readFile "input.txt" >>= (collapse >>> length >>> subtract 1 >>> print)