import Data.Char import Data.Bool import Data.List splitBy p xs | null xs = [] | isPrefixOf p xs = splitBy p (xs \\ p) | otherwise = if null ps then [xs] else (xs \\ head ps) : splitBy p (head ps) where ps = filter (isPrefixOf p) (tails xs) isSym c = (not.isAlphaNum) c && isPrint c main = interact $ unlines . map (bool "WRONG!" "CORRECT (maybe)" . daihon) . lines daihon str = case span (/= ' ') str of ("digi", (' ':srf)) -> (isSuffixOf "nyo") $ map toLower $ reverse $ dropWhile isSym $ take 6 $ reverse srf ("petit", (' ':srf)) -> (isSuffixOf "nyu") $ map toLower $ reverse $ dropWhile isSym $ take 6 $ reverse srf ("rabi", (' ':srf)) -> any isAlphaNum srf ("gema", (' ':srf)) -> (isSuffixOf "gema") $ map toLower $ reverse $ dropWhile isSym $ take 7 $ reverse srf ("piyo", (' ':srf)) -> (isSuffixOf "pyo") $ map toLower $ reverse $ dropWhile isSym $ take 6 $ reverse srf (_,(' ':"")) -> False _ -> False