Please see the image below to see the type of word game this post is about.
I have a text file of words that gets split and every word is added to an array.
With the 4 letters on the right side (of the image) is it possible to go through an array of words to find out how many words can be created from those 4 letters (BSTU). If this is possible does anyone know how I would go about it (I don’t need code just a point in the right direction). THANK YOU!
Each letter is a node which can optionally have a child for each character which represents the next character in the word. The blue checkmarks mean “The tree from the root to here represents a full word”.
Once you have this tree, you can use your pool of letters from your starting word (BSTU from your example) to recursively traverse this tree to build up all possible words you can make from those letters.
What I didn’t picture in my tree above is that the “root” node of the whole tree should actually be a “blank” character to represent an empty word, so that the word can begin with any character.