How about a recursive solution where you stop when you can no longer apply the remaining alphabet to the search space? That way you don't try all combinations, but only those that have a potential of succeeding.
# pseudocode sub find_some ( @choices, @alphabet ) { $results = []; for $choice ( @choices ) { if ( choice_is_in_alphabet ) { @new_choices = @choices - $choice; @new_alphabet = @alphabet - letters_in( $choice ); push @$results, [ $choice, find_some( @new_choices, @new_a +lphabet ) ]; } } return $results; }
You will be left with a spanning tree of all good solutions. With a stack you could also remove the recursion.
Update: Scope error
Update 2: I have noticed a couple of minor logic errors as well, but they appear to be easy enough to correct.
--MidLifeXis
In reply to Re: Another word puzzle with too many permutations
by MidLifeXis
in thread Another word puzzle with too many permutations
by sarchasm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |