From the CS olympiads:
binary in mult times 7 binary out ->
pythhon:(python code: int(raw_input(),base=2)*7

In my programs I usually only encounter 3 types of epic one liners, they all use the ternary conditional operator extensively.
(all in c++)

Type 1: Conditional arithmetic - When I want to change how an equation behaves based on conditions. Example taken directly from the add function of my integer library: (i<s?v[i]:0)+(i<o.s?o.v[i]:0)+(carry?1:0).

Type 2: Inline switch statements - Any switch statement can be made inline with the ternary operator.

switch (x)
    case A:doA();break;
    case B:doB();break;
    case C:doC();break;



Type 3: Complicated bitshifty stuff, typically to create inline hash functions. I can't think of a good example off hand, but they end up looking really cool.

However, I believe epic one liners are generally considered bad practice. That is why I try to keep a comment above each one that describes what the one-liner does.

I normally like to keep my code spaced, clear, and easy to read. So I don't normally have any epic one liners in any programming languages.

On the web design side, I have very messy CSS with some epic one liners, just some very long stylings on one line.

The only useful one-liner I know is in Pascal/Delphi:

asm int 3; end;

Conway's game of Life in one line of APL


Python baby ...

get the factorial of integer n

fact = lambda n:[1,0][n>1] or fact(n-1)*n

# test it ...

''' result ...

C ...
#define isleapyear(year) ((! (year % 4) && (year % 100)) || (! (year % 400) && (year % 1000)))