-- ACM Pacific NW Region Programming Contest, 11 November 2000 -- Problem E, Embedded Codes -- Sergio Antoy & Michael Hanus -- Mon Jun 25 09:54:29 PDT 2001 -- updated: Mon Sep 23 15:22:15 PDT 2002 -- hide s t n <==> t hides s by n hide [] _ _ = success hide (c:cs) t n = t =:= x++(c:ts) & length x+1 =:= n & hide cs ts n where x, ts free pp s [] = putStrLn (s ++ " is not found.") pp s (n:_) = putStrLn (s ++ " is found with encoding of " ++ show n ++ ".") exec embed text = pp embed (findall (\n -> hide embed text n)) parse_examples ("#":_) = done parse_examples (embeds:texts:exs) = do exec (rm_last embeds) (rm_last texts) parse_examples exs where rm_last = reverse . tail . reverse main = do input <- readFile "e.dat" parse_examples (lines input)