I wonder, if you open a text file in Python. And then you'd like to search of words containing a number of letters. 

Say you type in 6 different letters (a,b,c,d,e,f) you want to search.
You'd like to find words matching at least 3 letters.
Each letter can only appear once in a word.
And the letter 'a' always has to be containing. 

How should the code look like for this specific kind of search?
['https://Stackoverflow.com/questions/7518255', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/959397/']
Here is what I would do if I had to write this:

I'd have a function that, given a word, would check whether it satisfies the criteria and would return a boolean flag.

Then I'd have some code that would iterate over all words in the file, present each of them to the function, and print out those for which the function has returned `True`.
```
words = 'fubar cadre obsequious xray'

def find_words(src, required=[], letters=[], min_match=3):
    required = set(required)
    letters = set(letters)

    words = ((word, set(word)) for word in src.split())
    words = (word for word in words if word[1].issuperset(required))
    words = (word for word in words if len(word[1].intersection(letters)) >= min_match)
    words = (word[0] for word in words)
    return words

w = find_words(words, required=['a'], letters=['a', 'b', 'c', 'd', 'e', 'f'])
print list(w)

```

**EDIT 1:** I too didn't read the requirements closely enough. To ensure a word contains only 1 instance of a valid letter.

```
from collections import Counter

def valid(word, letters, min_match):
    """At least min_match, no more than one of any letter"""
    c = 0
    count = Counter(word)
    for letter in letters:
        char_count = count.get(letter, 0)
        if char_count > 1:
            return False
        elif char_count == 1:
            c += 1
        if c == min_match:
            return True
    return True

def find_words(srcfile, required=[], letters=[], min_match=3):
    required = set(required)
    words = (word for word in srcfile.split())
    words = (word for word in words if set(word).issuperset(required))
    words = (word for word in words if valid(word, letters, min_match))
    return words

```