Thus said Michael Torrie on Thu, 02 May 2013 22:13:33 -0600:

> Python version,  coded in 1 minutes,  well an extra minute  to run the
> REPL to make sure I had the slice syntax correct:

Except it doesn't produce the same output:

$ time ./strrev words > words.strrev
    0m0.11s real     0m0.11s user     0m0.00s system
$ time python mt.py < words > words.mt.py 
    0m0.61s real     0m0.59s user     0m0.00s system
$ md5 words.mt.py words.strrev 
MD5 (words.mt.py) = 25aa34ae2d9a16f3556233ca4e7593be
MD5 (words.strrev) = 9c75f40e4cdd3dfa9f9946eeb2c6010b

To correct this you need something like:

import sys

for x in map(str.strip,sys.stdin):
    print x[::-1]

$ time python mta.py < words > words.mta.py
    0m0.81s real     0m0.77s user     0m0.04s system
$ md5 words.mta.py words.strrev words.mt.py 
MD5 (words.mta.py) = 9c75f40e4cdd3dfa9f9946eeb2c6010b
MD5 (words.strrev) = 9c75f40e4cdd3dfa9f9946eeb2c6010b
MD5 (words.mt.py) = 25aa34ae2d9a16f3556233ca4e7593be

Cheers,

Andy
-- 
TAI64 timestamp: 4000000051834e4f



/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to