Re: how to insert random error in a programming

Discussion in 'Python' started by Mark Lawrence, Oct 15, 2012.

  1. On 15/10/2012 20:51, Chris Angelico wrote:
    > On Tue, Oct 16, 2012 at 6:28 AM, Mark Lawrence <> wrote:
    >> I like clearly written code like this
    >>
    >> "
    >> d = {}
    >> for c in (65, 97):
    >> for i in range(26):
    >> d[chr(i+c)] = chr((i+13) % 26 + c)
    >>
    >> print "".join([d.get(c, c) for c in s])

    >
    > Surely there's a shorter way to rot13 a piece of text? CODE GOLF!
    >
    > At very least, a single cryptic expression in place of your nice clear
    > loops MUST be an improvement.
    >
    > d = dict((chr(i+c),chr((i+13)%26+c))for i in range(26)for c in(65,97))
    >
    > And with superfluous spaces removed like that, it takes 0.02
    > jiggawatts less power in DeLorean Python.
    >
    > ChrisA
    >


    How dare you Sir, they're most certainly *NOT* my loops!!!

    --
    Cheers.

    Mark Lawrence.
     
    Mark Lawrence, Oct 15, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. globalrev
    Replies:
    4
    Views:
    796
    Gabriel Genellina
    Apr 20, 2008
  2. VK
    Replies:
    15
    Views:
    1,281
    Dr J R Stockton
    May 2, 2010
  3. Debashish Saha

    how to insert random error in a programming

    Debashish Saha, Oct 15, 2012, in forum: Python
    Replies:
    4
    Views:
    240
    Roy Smith
    Oct 16, 2012
  4. Chris Angelico
    Replies:
    0
    Views:
    157
    Chris Angelico
    Oct 15, 2012
  5. Jean-Michel Pichavant

    Re: how to insert random error in a programming

    Jean-Michel Pichavant, Oct 15, 2012, in forum: Python
    Replies:
    0
    Views:
    168
    Jean-Michel Pichavant
    Oct 15, 2012
Loading...

Share This Page