Re: who said python can't be obsfucated!?

2008-04-03 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
 def s(c):return[]if c==[]else s([_ for _ in c[1:]if _c[0]])+[c[0]]
 +s([_ for _ in c[1:]if _=c[0]])
 
 Anyone else got some wonders...?

Nothing as bad, but:

sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p 
in m.split('@')])

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who said python can't be obsfucated!?

2008-04-03 Thread Marco Mariani
Bruno Desthuilliers wrote:

 sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p 
 in m.split('@')])


Pff... you call that a quicksort?


 From http://www.p-nand-q.com/python/obfuscated_python.html


import sys

funcs = range(10)

def A(_,o):
 _[3]=_[5]()

def B(_,o):
 o[_[2]]=_[9]()

def C(_,o):
 _[3]=_[7]()

def D(_,o):
 o[_[1]]=_[14]()

def E(_,o):
 _[1]=_[4]()

def F(_,o):
 _[2]=_[6]()

def G(_,o,O):
 if _[O[0]]():return O[-1](_,o) or 1

def H(o, start, stop):
 _=[o[stop],[lambda x,y:x+y,lambda x,y:x-y,lambda x,
 y:y|1,0,0][1](start,funcs[4](range(funcs[3](),
 len(o[:],stop,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

 for i in range(4,19):
 _[i]=lambda _=_,o=o,s=reduce([lambda x,y:x+y,lambda \
   x,y:x-y,lambda x,y:y|1,0,0][0],[_[1],funcs[4](\
   range(eval(\funcs[3]()\),_[10]()))])$funcs[4\
   ](range(eval(\funcs[3]()\),_[10]()))$[lambda\
x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][1]\
   (_[2],funcs[4](range(funcs[3](),_[10]($fun\
   cs[4](range(funcs[3](),_[10]()))$range(_[10]()\
   *_[10]())$o[:][_[1]]$len(o[:])$not _[3]$_[1]==\
   _[2]$o[:][_[1]]_[0]$o[:][_[2]]$o[_[2]]_[0]$_\
   [2]==_[1]$_[11]() and not E(_,0) and not G(_,o\
   ,[12,A]) and not G(_,o,[13,B])$_[11]() and not\
F(_,_) and not G(_,o,[16,C]) and not G(_,o,[1\
   5,D]).split('$')[:][i-4]:eval(eval('eval(s)'))

 while _[11]():
 while _[17](): pass
 while _[18](): pass
 o[_[2]] = _[0]
 return _[2]

def quicksort(list,start,stop):
 exec('funcs[3] = lambda:reduce([lambda x,y:x+y,lambda x,y'\
  ':x-y,lambda x,y:y|1,0,0][1],[[lambda x,y:x+y,lambda'\
  ' x,y:x-y,lambda x,y:y|1,0,0][2](200,200)]*2)\nfuncs'\
  '[4] = lambda x:reduce(lambda x,y:y%2,range(eval(re'\
  'duce([lambda x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,'\
  '0,0][2],[len(o[:]),len(o[:])])),eval(reduce([lamb'\
  'da x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][2],[l'\
  'en(o[:]),len(o[:])]))+((len(o)and 3)or 3)))\nif st'\
  'art  stop:\n\tsplit = H(list, start, stop)\n\tquic'\
  'ksort(list, start, [lambda x,y:x+y,lambda x,y:x-y,l'\
  'ambda x,y: y|1,0,0][1](split,funcs[4](funcs[3]('\
  '\n\tquicksort(list, reduce([lambda x,y:x+y,lambda x'\
  ',y:x-y,lambda x,y:y|1,0,0][0],[split,funcs[4](funcs'\
  '[3]())]), stop)\n')

# test code: 2000 elements to sort
list = []
import whrandom,time
for i in range(2000):
 list.append(whrandom.randint(1,100))
start = time.clock()
quicksort(list,0,len(list)-1)
print Sorting took %.2f % (time.clock() - start)

# just a test loop to see if everything *is* sorted
element = -1
for i in list:
 if i = element:
 element = i
 else:
 print FUNK DAT: %20s % str(i)
 break

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who said python can't be obsfucated!?

2008-04-03 Thread Marco Mariani
Bruno Desthuilliers wrote:

 sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p 
 in m.split('@')])


Pff... you call that a quicksort?


 From http://www.p-nand-q.com/python/obfuscated_python.html


import sys

funcs = range(10)

def A(_,o):
 _[3]=_[5]()

def B(_,o):
 o[_[2]]=_[9]()

def C(_,o):
 _[3]=_[7]()

def D(_,o):
 o[_[1]]=_[14]()

def E(_,o):
 _[1]=_[4]()

def F(_,o):
 _[2]=_[6]()

def G(_,o,O):
 if _[O[0]]():return O[-1](_,o) or 1

def H(o, start, stop):
 _=[o[stop],[lambda x,y:x+y,lambda x,y:x-y,lambda x,
 y:y|1,0,0][1](start,funcs[4](range(funcs[3](),
 len(o[:],stop,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

 for i in range(4,19):
 _[i]=lambda _=_,o=o,s=reduce([lambda x,y:x+y,lambda \
   x,y:x-y,lambda x,y:y|1,0,0][0],[_[1],funcs[4](\
   range(eval(\funcs[3]()\),_[10]()))])$funcs[4\
   ](range(eval(\funcs[3]()\),_[10]()))$[lambda\
x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][1]\
   (_[2],funcs[4](range(funcs[3](),_[10]($fun\
   cs[4](range(funcs[3](),_[10]()))$range(_[10]()\
   *_[10]())$o[:][_[1]]$len(o[:])$not _[3]$_[1]==\
   _[2]$o[:][_[1]]_[0]$o[:][_[2]]$o[_[2]]_[0]$_\
   [2]==_[1]$_[11]() and not E(_,0) and not G(_,o\
   ,[12,A]) and not G(_,o,[13,B])$_[11]() and not\
F(_,_) and not G(_,o,[16,C]) and not G(_,o,[1\
   5,D]).split('$')[:][i-4]:eval(eval('eval(s)'))

 while _[11]():
 while _[17](): pass
 while _[18](): pass
 o[_[2]] = _[0]
 return _[2]

def quicksort(list,start,stop):
 exec('funcs[3] = lambda:reduce([lambda x,y:x+y,lambda x,y'\
  ':x-y,lambda x,y:y|1,0,0][1],[[lambda x,y:x+y,lambda'\
  ' x,y:x-y,lambda x,y:y|1,0,0][2](200,200)]*2)\nfuncs'\
  '[4] = lambda x:reduce(lambda x,y:y%2,range(eval(re'\
  'duce([lambda x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,'\
  '0,0][2],[len(o[:]),len(o[:])])),eval(reduce([lamb'\
  'da x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][2],[l'\
  'en(o[:]),len(o[:])]))+((len(o)and 3)or 3)))\nif st'\
  'art  stop:\n\tsplit = H(list, start, stop)\n\tquic'\
  'ksort(list, start, [lambda x,y:x+y,lambda x,y:x-y,l'\
  'ambda x,y: y|1,0,0][1](split,funcs[4](funcs[3]('\
  '\n\tquicksort(list, reduce([lambda x,y:x+y,lambda x'\
  ',y:x-y,lambda x,y:y|1,0,0][0],[split,funcs[4](funcs'\
  '[3]())]), stop)\n')

# test code: 2000 elements to sort
list = []
import whrandom,time
for i in range(2000):
 list.append(whrandom.randint(1,100))
start = time.clock()
quicksort(list,0,len(list)-1)
print Sorting took %.2f % (time.clock() - start)

# just a test loop to see if everything *is* sorted
element = -1
for i in list:
 if i = element:
 element = i
 else:
 print FUNK DAT: %20s % str(i)
 break

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who said python can't be obsfucated!?

2008-04-03 Thread Bruno Desthuilliers
Marco Mariani a écrit :
 Bruno Desthuilliers wrote:
 
 sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p 
 in m.split('@')])
 
 
 Pff... you call that a quicksort?
 

Nope, only somewhat obfuscated Python. And it seems it's at least 
obfuscated enough for you to believe it could be a quicksort 
implementation !-)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who said python can't be obsfucated!?

2008-04-03 Thread Marco Mariani
Bruno Desthuilliers wrote:

 Pff... you call that a quicksort?

 Nope, only somewhat obfuscated Python. And it seems it's at least 
 obfuscated enough for you to believe it could be a quicksort 
 implementation !-)

You're right, but I'm past the quine age and don't bother parsing 
obfuscated code (*) anymore.




(*) outside my day job, that is.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who said python can't be obsfucated!?

2008-04-02 Thread Paddy
On Apr 2, 2:19 pm, [EMAIL PROTECTED] wrote:
 def s(c):return[]if c==[]else s([_ for _ in c[1:]if _c[0]])+[c[0]]
 +s([_ for _ in c[1:]if _=c[0]])

 Anyone else got some wonders...?

Nope.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who said python can't be obsfucated!?

2008-04-02 Thread Francesco Bochicchio
On Wed, 02 Apr 2008 07:19:08 -0700, cokofreedom wrote:

 def s(c):return[]if c==[]else s([_ for _ in c[1:]if _c[0]])+[c[0]]
 +s([_ for _ in c[1:]if _=c[0]])
 
 Anyone else got some wonders...?

Not so good: it took me only one minute to anderstand that is a 
recursive sort ... or it is?

I read it as:

the function s applied to a list is equal to the empty list if the
input list is empty, otherwise it is equal to the result of the function s
applied to all the elements smaller than the first one plus the first
element plus the function sort applied to all the elements greater or
equal to the first one, except the first one itself.


I like the almost one-to-one corrispondence between the code elements and
the components of the sentence describing the function. Now _that_ is
an human-friendly syntax :-)


Ciao

FB
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who said python can't be obsfucated!?

2008-04-02 Thread bearophileHUGS
cokofree...:
 def s(c):return[]if c==[]else s([_ for _ in c[1:]if _c[0]])+[c[0]]+s([_ for 
 _ in c[1:]if _=c[0]])

That QuickSort can be written as a lambda too:

s=lambda l:[]if l==[]else s([x for x in l[1:]if xl[0]])+[l[0]]+s([x
for x in l[1:]if x=l[0]])

Bye,
bearophile
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who said python can't be obsfucated!?

2008-04-02 Thread Jon Nicoll
[EMAIL PROTECTED] wrote:

 def s(c):return[]if c==[]else s([_ for _ in c[1:]if _c[0]])+[c[0]]
 +s([_ for _ in c[1:]if _=c[0]])
 
 Anyone else got some wonders...?


looks like one of castironpi's postings...

J^n
-- 
http://mail.python.org/mailman/listinfo/python-list