Find 6-letter words that are hidden (embedded) within

David Raymond David.Raymond at tomtom.com
Fri Feb 24 16:16:17 EST 2023


> Find 6-letter words that are hidden (embedded) within each row of letters. 
>                                 The letters are in the correct order. 
> 
> 1. JSOYOMFUBELR 
> 2. SCDUARWDRLYE 
> 3. DASNAGEFERTY 
> 4. CLULOOTSCEHN 
> 5. USENEARSEYNE

> The letters are in the correct order. -------- So this problem is not about Anagraming.


You can get every combination of 6 letters out of it with itertools.combinations like below.
Just implement the isWord function to return whether a string actually counts as a legit word or not.
12 choose 6 is only 924 combinations to check, so shouldn't be too bad to check them all.


def isWord(word):
    return True #Best left as an exercise to the reader

startWord = "JSOYOMFUBELR"
subLetterCount = 6

foundWords = set()

for letters in itertools.combinations(startWord, subLetterCount):
    word = "".join(letters)
    if word not in foundWords and isWord(word):
        print(word)
        foundWords.add(word)


More information about the Python-list mailing list