> 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)
--
https://mail.python.org/mailman/listinfo/python-list