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

Hen Hanna henhanna at gmail.com
Fri Feb 24 15:15:22 EST 2023


On Friday, February 24, 2023 at 10:34:31 AM UTC-8, Hen Hanna wrote:
> i just wrote a program, which... 
>                within [FunFunPython] 
>                finds: (funny, futon, python) 
> 
>                                ( 5- and 6- letter words ) 
> 
> 
> (my program uses a Trie, but is pretty simple) 
> 
> 
> 
> Maybe someone would show me 
>                   how it's done using itertools, Permutations, etc. 
> 
> Wouldn't it get too slow for Letter-Seeds longer than 11 letters or so? 
> 
> 
> ______________________ 
> 
> 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.



it seems that 
https://docs.python.org/3/library/itertools.html
doesn't offer waht i want, so i wrote this (below) and it works.

                           Is there a better or faster way to do the same thing?


def subs( x ): 
    if x=='':   return  ['']
    x1= subs( x[1:] )
    return x1 + mapAdd(x[0] , x1)

def mapAdd( x, Ylis ):    return [ x+y for y in Ylis ]

print( subs('ab' ))
print( subs('abc' ))


More information about the Python-list mailing list