We've made it somewhat easier to contribute programs.
No need to subscribe to the mailing-list.
No need for a user-id or login.
See the FAQ "How can I contribute a program?"
http://shootout.alioth.debian.org/faq.php
--
http://mail.python.org/mailman/listinfo/python-list
import sys
import string
def show(seq, table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
'TGVHCDM\nKNSYAAWBRTGVHCDMKNSYAAWBR')):
seq = seq.translate(table)[::-1]
for i in range(0, len(seq), 60):
print seq[i:i+60]
couldn't you chang
> > . import string, itertools, sys
> > .
> > . t = string.maketrans('ACBDGHKMNSRUTWVYacbdghkmnsrutwvy',
> > . 'TGVHCDMKNSYAAWBRTGVHCDMKNSYAAWBR')
> > .
> > . for h,b in itertools.groupby( file(sys.argv[1]), lambda x: x[0] in
> > ">;" ):
> > . if h:
> > . print "".j
On Wed, 16 Mar 2005 16:45:53 -0800, bearophileHUGS wrote:
> Michael Spencer's version is nice, this is a bit shortened version. The
> main() isn't useful for this very short loop, and you can use shorter
> variable names to make lines shorter (this code isn't much readable,
> it's just for the Sho
Michael Spencer's version is nice, this is a bit shortened version. The
main() isn't useful for this very short loop, and you can use shorter
variable names to make lines shorter (this code isn't much readable,
it's just for the Shootout, "production quality" code has probably to
be more readable.
Steven Bethard wrote:
Michael Spencer wrote:
def output(seq, linelength = 60):
if seq:
iterseq = iter(seq)
while iterseq:
print "".join(islice(iterseq,linelength))
Worth noting: "while iterseq" only works because for this case, you have
a list iterator, which provi
Jacob Lee wrote:
>> # alias methods to avoid repeated lookup
>> join = ''.join
I would actually do the alias here sometimes, but give it a
semantically-useful name ...
nosep_join = ''.join
...
Tim Delaney
--
http://mail.python.org/mailman/listinfo/python-list
Michael Spencer wrote:
def output(seq, linelength = 60):
if seq:
iterseq = iter(seq)
while iterseq:
print "".join(islice(iterseq,linelength))
Worth noting: "while iterseq" only works because for this case, you have
a list iterator, which provides a __len__ method.
F. Petitjean wrote:
Le Tue, 15 Mar 2005 23:21:02 -0800, Michael Spencer a écrit :
def output(seq, linelength = 60):
if seq:
iterseq = iter(seq)
while iterseq:
print "".join(islice(iterseq,linelength))
I suppose you mean :
print "".join( str(item) for item
Consider keeping the alias for append because it occurs in the
innermost loop. For maximum readability, write: addline = seq.append
Move the ''.join() to the show() function. That eliminates a little
redundancy.
The test dataset doesn't use the semi-colon comment field. So,
consider reversin
Le Tue, 15 Mar 2005 23:21:02 -0800, Michael Spencer a écrit :
> Jacob Lee wrote:
>> On Tue, 15 Mar 2005 21:38:48 -0800, Michael Spencer wrote:
>>
>> Good call.
>>
>>
>
> How about this then:
>
> basetable = string.maketrans('ACBDGHKMNSRUTWVYacbdghkmnsrutwvy',
> 'T
Jacob Lee wrote:
On Tue, 15 Mar 2005 21:38:48 -0800, Michael Spencer wrote:
string.translate is a good idea. Note you can handle upper-casing and
translation in one operation by adding a mapping from lower case to the
complement i.e.,
table = string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
Jacob Lee wrote:
So here's a tentative contest version of the code:
import sys
import string
def show(seq, table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
'TGVHCDM\nKNSYAAWBRTGVHCDMKNSYAAWBR')):
seq = seq.translate(table)[::-1]
for i in ra
On Tue, 15 Mar 2005 22:45:48 -0700, Steven Bethard wrote:
> # table as default argument value so you don't have to do
> # a global lookup each time it's used
>
> def show(seq, table=string.maketrans('ACBDGHK\nMNSRUTWVY',
> 'TGVHCDM\nKNSYAAWBR')
> seq = s
On Tue, 15 Mar 2005 21:38:48 -0800, Michael Spencer wrote:
> string.translate is a good idea. Note you can handle upper-casing and
> translation in one operation by adding a mapping from lower case to the
> complement i.e.,
>
> table = string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
>
Jacob Lee wrote:
There are a bunch of new tests up at shootout.alioth.debian.org for which
Python does not yet have code. I've taken a crack at one of them, a task
to print the reverse complement of a gene transcription. Since there are a
lot of minds on this newsgroup that are much better at optim
Here's my solution to the problem[1]:
[1] http://shootout.alioth.debian.org/benchmark.php?test=revcomp
import sys
import string
basetable = string.maketrans('ACBDGHKMNSRUTWVYacbdghkmnsrutwvy',
'TGVHCDMKNSYAAWBRTGVHCDMKNSYAAWBR')
def revcomp(seqlines, linelength=60, base
Jacob Lee wrote:
There are a bunch of new tests up at shootout.alioth.debian.org for which
Python does not yet have code. I've taken a crack at one of them, a task
to print the reverse complement of a gene transcription. Since there are a
lot of minds on this newsgroup that are much better at optim
Jacob Lee wrote:
By the way - is there a good way to find out the maximum memory a program
used (in the manner of the "time" command)? Other than downloading and
running the shootout benchmark scripts, of course.
Inserting appropriate pauses with raw_input() and recording the memory
usage using to
There are a bunch of new tests up at shootout.alioth.debian.org for which
Python does not yet have code. I've taken a crack at one of them, a task
to print the reverse complement of a gene transcription. Since there are a
lot of minds on this newsgroup that are much better at optimization than
I, I
20 matches
Mail list logo