
26 May
2007
26 May
'07
10:11 p.m.
Jason Dagit wrote:
Given a word, find all the words in the dictionary which can be made from the letters of that word. A letter can be used at most as many times as it appears in the input word. So, "letter" can only match words with 0, 1, or 2 t's in them.
I don't know about the ByteString thing but how about a general speedup? frequencies = map (\x -> (head x, length x)) . group . sort superset xs = \ys -> let y = frequencies ys in length y == lx && and (zipWith (\(c,i) (d,j) -> c == d && i >= j) x y) where x = frequencies xs lx = length x main = interact $ unlines . filter ("ubuntu" `superset`) . lines Regards, apfelmus