On Friday, February 24, 2023 at 1:18:28 PM UTC-8, David Raymond wrote: > > 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)
thank you... i could use the Pset below, too. # Factorial Python One-Liner def fac(n): return reduce(lambda x, y: x * y, range(1, n+1)) for i in range(1,11): print ( '\t', fac(i) ) # Power set Python One-Liner def Pset(L): return reduce(lambda z, x: z + [y + [x] for y in z], L, [[]]) print( '\n', Pset( [1,] )) print( '\n', Pset( [1,2,] )) print( '\n', Pset( [1,2,3] )) -- https://mail.python.org/mailman/listinfo/python-list