puzzle/joke ;-)

Andrew Dalke dalke at acm.org
Fri May 4 10:44:48 CEST 2001


Volucris wrote
>def blip():
>    blop = '\'\"' + '\\'*129 + '\'\"'
>    for x in range(6, 0, -1):
>        if x == 6:
>            offset = 0
>        else:
>            offset = 1
>        seq = (2**(x)-offset)*'\\'
>        blop = '\'' + seq + blop + seq + '\''
>    return blop + '\''

I count about 235 characters in that.  Consider instead

import
zlib;zlib.decompress('x\234SW\217Q\217\211\001\343\030$:\006\007\037\003\250
+\021RA\271\011\270\034\005q\270\272\272:\000\025\204C>')

which is 68 characters if the \ escapes are counted as one character or
142 characters if you want the 7-bit clean expansion.

BTW, you could shrink your code with
  offset = 1-(x==6)
and of course using single character variable names.

But I don't see the point of this puzzle.

                    Andrew






More information about the Python-list mailing list