Rate my obsfucated code?

A forum for general discussion of the Python programming language.

Rate my obsfucated code?

Postby russ » Mon Apr 08, 2013 5:40 pm

This is what the sieve looks like:
Code: Select all
def prime_sieve(upper):
    '''
    prime_sieve(upper) -> list of primes up to upper (not including)
    '''
    nums = range(upper)
    p = 2
    end = pow(upper, 0.5) + 1
    while p < end:
        for m in xrange(p + p, upper, p):
            nums[m] = 0
        while True:
            p += 1
            if nums[p]:
                break
    return [n for n in nums[2:] if n]


And after about an hour this is what I got. It's a good bit slower but I think it's because of the j function which is what "marks of multiples of p".

Code: Select all
def j(f): f[1][f[0]] = 0
def p1(upper):
    return (lambda q:[z for z in (lambda h:[map((lambda x: None if not x[1] else map(lambda l: j(l),[(t,h) for t in range(x[1]*2,len(x[0]),x[1])])), [(h,s) for s in h[2:int(int(len(h)**0.5)+1)]]),h][1])(range(q))[2:] if z])(upper)
russ
 
Posts: 18
Joined: Sat Mar 02, 2013 8:59 am

Re: Rate my obsfucated code?

Postby Yoriz » Mon Apr 08, 2013 6:19 pm

Code: Select all
float('-inf')
-inf
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 725
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Rate my obsfucated code?

Postby russ » Mon Apr 08, 2013 6:45 pm

Which law does it violate, the rate my code question or the act ot trying to obfuscate python? :lol: probably both
russ
 
Posts: 18
Joined: Sat Mar 02, 2013 8:59 am


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests