I am abstracting a real world problem into the following question:
- X is a pool of all possible permutation of letters.
- Y is a pool of strings.
- F is a function that takes a candidate x from X and returns a boolean value depending on whether x belongs to Y.
F is expensive and X is huge.
What is the most efficient way to extract as many results from Y as possible? False positives are ok.
Introduce another function G which is cheap and also tests whether x belongs to y. G must return true whenever F returns true, and may return true when F returns false. First test with G, testing with F only if G returns true.
I don’t see how to say anything more specific, considering the generality of your formulation.