> Hum, since your code is not syntactically correct, anything will run
> faster :)
in fact it parses, I was fooled by this line
>> if k in range(1,len(prunedK),1) & i+k <= len(prunedK) -1:
I was fooled because the form "k in range(" tends to imply a for statement ;
in the case of an
[EMAIL PROTECTED] wrote:
> It's not that difficult to improve the readability of a quite long
> line, you can start splitting it.
The point is that it is observer and context dependent whether
res = set(''.join(sorted(X|Y))
for X in sets
for Y in sets
[EMAIL PROTECTED] wrote:
> Boris Borcic:
>>> I don't do challenges.
>> Pfff... and you don't do real debates either.
>
> Different nations have different values and different cultures, in mine
> challenges are often seen as things for children, and a waste of time
> for adults (probably in USA cha
Boris Borcic:
> > I don't do challenges.
>
> Pfff... and you don't do real debates either.
Different nations have different values and different cultures, in mine
challenges are often seen as things for children, and a waste of time
for adults (probably in USA challenges are appreciated more).
By
[EMAIL PROTECTED] wrote:
> Boris Borcic:
>
>> I challenge you to write simpler code to do the equivalent.
context ?
>
> I don't do challenges.
Pfff... and you don't do real debates either.
> I too have written the code to solve that
> problem,
Why ? When ?
--
http://mail.python.org/mailman/
Boris Borcic:
> I challenge you to write simpler code to do the equivalent.
I don't do challenges. I too have written the code to solve that
problem, it wasn't much different from your one (it uses a generator
function xpairs, to yeild a scan of the different pairs, about half the
square, it uses
[EMAIL PROTECTED] 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
> I think there can be written more readable code. For my programs I
> usually prefer simpler code, that (if possible) even a children can
> understand. So I can debug, modify and improve it better & faster.
Debugged:
I think it can be written more readable code.
In this newsgroup sometimes I have
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. For my programs I
usually prefer simpler code, that (if possib
Jon Clements wrote:
> Are you asking the question, "Which pairs of strings have one character
> different in each?", or "Which pairs of strings have a substring of
> len(string) - 1 in common?".
>
> Jon.
I imagine it's the former because the latter is trivially easy, I mean
_really_ trivially eas
Girish Sahani wrote:
> I have a list of strings all of length k. For every pair of k length
> strings which have k-1 characters in common, i want to generate a k+1
> length string(the k-1 common characters + 2 not common characters).
> e.g i want to join 'abcd' with bcde' to get 'abcde' but i dont
Are you asking the question, "Which pairs of strings have one character
different in each?", or "Which pairs of strings have a substring of
len(string) - 1 in common?".
Jon.
Girish Sahani wrote:
> I have a list of strings all of length k. For every pair of k length
> strings which have k-1 charac
So yeah, just to put it all together, try this. From your two Ks, it
either returns K+1 if it can or an empty string.
def k2k1(string1, string2):
for c in string1:
string2 = string2.replace(c,"",1)
if len(string2) == 1:
string1 += string2
else:
string1 = ""
actually, minor fix:
MTD wrote:
> Try this:
>
> def k2k1(string1, string2):
> for c in string1:
> string2 = string2.replace(c,"",1)
>
> if len(string2) == 1:
> string1 += string2
else:
string1 = ""
>
> return string1
>
> print k2k1("abcd", "ebcd
Try this:
def k2k1(string1, string2):
for c in string1:
string2 = string2.replace(c,"",1)
if len(string2) == 1:
string1 += string2
return string1
print k2k1("abcd", "ebcd")
--
http://mail.python.org/mailman/listinfo/python-list
I have a list of strings all of length k. For every pair of k length
strings which have k-1 characters in common, i want to generate a k+1
length string(the k-1 common characters + 2 not common characters).
e.g i want to join 'abcd' with bcde' to get 'abcde' but i dont want to
join 'abcd' with 'c
16 matches
Mail list logo