I am thinking about this all day and can't seem to figure out an memory efficient and speedy way. The problem is:
for example, I have these letters: e f j l n r r t t u w x (12 letters)
I am looking for this word TURTLE (6 letters)
How do I find all the possible words in the full range (12 words) with php? ( Or with python, if that might be a lot easier? )
Things I've tried:
Using permutations: I have made all strings possible using a permutation algorithm, put them in array (only the ones 6 chars long) and do an in_array to check if it matches one of the words in my array with valid words (in this case, containing TURTLE, but sometimes two or three words). This calculating costs a lot of memory and time, especially with 6+ characters to get permutations of.
creating a regex (I am bad at this). I wanted to create a regex to check if 6 of the 12 (input) characters are in a word from the "valid array". problem is, we don't know what letter from the 12 will be the starting position and the position of the other words.
An example of this would be: http://drawsomethingwords.net/
I hope you can help me with this problem, as I would really like to fix this. Thanks for all of your time :)