import Control.Monad as M import Data.Text as T main = M.replicateM 3 getLine >>= print . solve . parse parse :: [String] -> [Int] parse colors = Prelude.map countEaten colors where countEaten "NONE" = 0 countEaten color = Prelude.length $ T.splitOn (T.pack ",") (T.pack color) solve :: [Int] -> Int solve = Prelude.foldl1 (*) . Prelude.map (\x -> (16 - x) ^ 2)