How to generate k+1 length strings from a list of k length strings?
Boris Borcic
bborcic at gmail.com
Thu Jun 8 13:59:10 EDT 2006
bearophileHUGS at lycos.com wrote:
> Boris Borcic:
>> I'd favor the following, that I find most readable
>> sets = map(set,list_of_strings)
>> res = set(''.join(sorted(s1|s2)) for s1 in sets for s2 in sets if len(s1^s2)==2)
>
> I think there can be written more readable code.
readability, of course, is in the eye of the beholder... and I find this code
*much* easier to recognize as a realisation of the description made by the OP,
than the code he himself offered - if you care to take a look at both.
For my programs I
> usually prefer simpler code,
I challenge you to write simpler code to do the equivalent.
> that (if possible) even a children can
> understand.
what child ? one that is trained just like *you* think children should start, I
guess.
> So I can debug, modify and improve it better & faster.
Sure, but the case is we each were *distinct* children.
>
> Bye,
> bearophile
>
More information about the Python-list
mailing list