In today’s Programming Praxis exercise, our goal is to find two words that consist of the letters A through F and two other letters. Let’s get started, shall we?
Checking if a word is valid is a simple matter of checking whether it has eight letters and whether it contains all six required letters.
npr :: String -> Bool npr s = length s == 8 && null ("abcdef" \\ s)
With that out of the way, all that’s left to do is to search all the words in the ddictionary for the ones the satisfy the criterium.
main :: IO () main = mapM_ print . filter npr . lines =<< readFile "en_US.dic"
As expected, the only words found are boldface and feedback.