情報オリンピック 第18回 マヤ語の文献の解読

http://www.ioi-jp.org/ioi/2006/problem/index.htm
こんなんでどうだ。

import Data.List (elem, delete)

counts :: String -> String -> Int
counts s1 s2 = length $ filter (== True) $ f s1 s2

f :: String -> String -> [Bool]
f _ [] = [True]
f [] _ = [False]
f s1@(x:xs) s2 = [containsAll (take (length s2) s1) s2] ++ f xs s2

containsAll :: String -> String -> Bool
containsAll _ [] = True
containsAll s1@(x:xs) s2
    | length s1 /= length s2 = False
    | otherwise = case elem x s2 of
                             True  -> containsAll xs (delete x s2)
                             False -> False