(a==b) ? 'Yes' : 'No'

Tim Chase python.list at tim.thechases.com
Fri Apr 2 10:52:36 EDT 2010


Steve Howell wrote:
> I forgot this one:
> 
> def obfuscated_triager(rolls, pins,
>         lookup = ['normal'] * 10 + ['strike'] + [None] * 9 + ['spare']
>         ):
>     return lookup[rolls * pins]

Bah...no need to be _quite_ so obscure:
   def triager(rolls, pins):
     return {
       (1, 10):'strike',
       (2,10):'spare',
       (2,0):'wow, you stink',
       }.get((rolls, pins), 'normal')


;-)

-tkc






More information about the Python-list mailing list