Jump to content

  • Log In with Google      Sign In   
  • Create Account


My greatest triumph

  • You cannot reply to this topic
4 replies to this topic

#1 Facehat   Members   -  Reputation: 696

Like
5Likes
Like

Posted 25 February 2013 - 03:12 PM

Like many languages, python has a distinction between "statements" and "expressions". I wanted to see if I could write an entire program only using expressions.

 

BEHOLD! THE TRIANGLE PRINTER!

 

(lambda:
    not globals().__setitem__('sys', __import__('sys'))
    and not globals().__setitem__('this', sys.modules[globals()['__name__']])
    and not globals().__setitem__('time', __import__('time'))
    and
    #program
    [setattr(this, k, v) for k,v in {
            'set_color': (lambda c: w(['*', ' '][c])),
            'abs': (lambda t: (t + (t >> 31)) ^ (t >> 31)),
            'w': sys.stdout.write,
            'smash': (lambda t: -((t * -1) >> 31)),
            'color': (lambda n,k: set_color(smash (k & (n - k)))),
            'col': (lambda n, k: k <= n and not color(n,k) and col(n,k + 1)),
            'row': (lambda n: not w(' ' * (40-abs(n/2)))
                              and (col(abs(n), 0) or True)
                              and not w("\n")
                              and (abs(n) < 63 or n < 0)
                              and not time.sleep(0.05)
                              and row(n+1)),
            'triangle': lambda: row(-60) or True and triangle()
        }.items() ] and triangle() )()

 



Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 14623

Like
3Likes
Like

Posted 25 February 2013 - 03:31 PM

You perverse sonofabitch.

#3 Facehat   Members   -  Reputation: 696

Like
2Likes
Like

Posted 25 February 2013 - 03:47 PM

I feel like using list comprehensions to set global function definitions on the currently running namespace is an underappreciated art.



#4 FLeBlanc   Crossbones+   -  Reputation: 3085

Like
1Likes
Like

Posted 25 February 2013 - 04:42 PM

Man, I needed a good chuckle this afternoon.



#5 Alpha_ProgDes   Crossbones+   -  Reputation: 4688

Like
0Likes
Like

Posted 25 February 2013 - 08:44 PM

Dear God, man. Does the compiler even allow you to write code anymore?

 

Note: That's pretty impressive. I'm glad I don't have to deal with it though :)


Beginner in Game Development? Read here.
 
Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley
 
If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts Posted Image
 
Spoiler





PARTNERS