PEP 308: Obfuscated Nested Ternaries (INACAIS)

Andrew Bennetts andrew-pythonlist at puzzling.org
Thu Feb 20 17:59:58 EST 2003


On Thu, Feb 20, 2003 at 03:00:42PM +0100, Gerrit Holl wrote:
> Hi,
> 
> For the Obfuscated Contest: rewrite this peace of code
> using ternaries. Preferably with a lot of ('s and )'s :)
> 
>     if x > 0:
>         if y > 0:
>             seq = (tl, br, b, br, r, br)
>         elif y == 0:
>             seq = (l, r, t, r, b, r)
>         else:
>             seq = (bl, tr, t, tr, r, tr)
>     elif x == 0:
>         if y > 0:
>             seq = (t, b, l, b, r, b)
>         elif y == 0:
>             seq = (tl, tr, br, bl, tl)
                    ^^^^^^^^^^^^^^^^^^^^
                    This looks buggy to me; why only 5 elements?

-Andrew.






More information about the Python-list mailing list