All possible combinations of letters

I’m trying to create a game like the countdown TV show and am currently onto the letters round. However, I am having trouble figuring out how to create a function that finds a maximum of 5 words for each length of word(1-9 letters long) based on a list of nine letters that was previously chosen by the user. Any time I have tried this with a function that just iterates through the list, finds all possible ways of combining the 9 letters for that word length, and checks if it is in the dictionary list, the game engine ends up crashing and/or not responding when I get towards finding words of length 7+. Any help or ideas on how to approach this would be much appreciated.
Thanks :grinning:

Explains in detail how to search for large amounts of words.

watch from minute 21

Example:
Dictionary of 1024 words - search only 10 times
Dictionary of 1048576 words - search only 20 times

A simple idea is that you build an indexing of your dictionary words. For example:
Your dict { “abc”, “aab”, “aac”, “abb”, “aba” }
=> Indexing { “a” = { “ab” = { “abc”, “abb”, “aba” }, “aa” = { “aab”, “aac” } } }

When finding you just need to go through by its key