never executed always true always false
    1 {-|
    2 Module:      Y2018.D05
    3 Description: Advent of Code Day 03 Solutions.
    4 License:     MIT
    5 Maintainer:  @tylerjl
    6 
    7 Solutions to the day 05 set of problems for <adventofcode.com>.
    8 -}
    9 module Y2018.D05
   10   ( react
   11   , reactBest
   12   )
   13 where
   14 
   15 import Data.Char (toLower, toUpper)
   16 import Data.List (nub)
   17 
   18 reactBest :: String -> Int
   19 reactBest input = minimum $ map react $ map inputWithout candidates
   20   where candidates = nub $ map toUpper input
   21         inputWithout c = filter (not . sameLetter c) input
   22         sameLetter x y = (toUpper x) == y || (toLower x) == y
   23 
   24 react :: String -> Int
   25 react = length . foldr collapse ""
   26   where collapse piece l@(x:xs) | reactive piece x = xs
   27                                 | otherwise = [piece] ++ l
   28         collapse piece [] = [piece]
   29         reactive a b = a /= b && toUpper a == toUpper b