Fun python 3.2 one-liner
geremy condra
debatem1 at gmail.com
Tue Mar 29 14:45:05 EDT 2011
On Tue, Mar 29, 2011 at 11:24 AM, Raymond Hettinger <python at rcn.com> wrote:
>>>> print('\n'.join('*'*(c//2000) for _,c in sorted(Counter(map(sum, product(range(6), repeat=8))).items())))
>
>
>
>
>
>
>
>
> *
> ***
> *****
> ********
> ************
> ******************
> *************************
> ********************************
> *****************************************
> *************************************************
> ********************************************************
> **************************************************************
> ******************************************************************
> *******************************************************************
> ******************************************************************
> **************************************************************
> ********************************************************
> *************************************************
> *****************************************
> ********************************
> *************************
> ******************
> ************
> ********
> *****
> ***
> *
>
>
>
> Re-posting (forgot to attach the output).
> Besides the interesting output, other
> interesting virtues include very low
> memory usage and that the inner-loop
> pipeline runs entirely in C.
Another (related) 3.2 one liner:
from math import erf, sqrt
def normal_cdf(x, mu=0, sigma=1): return (1/2) * (1 +
erf((x-mu)/(sigma*sqrt(2))))
approximates the cumulative distribution function of the normal distribution.
Geremy Condra
More information about the Python-list
mailing list