Dennis Lee Bieber wrote:
> On Thu, 04 Aug 2005 20:59:33 -0500, "Terrance N. Phillip"
> <[EMAIL PROTECTED]> declaimed the following in
> comp.lang.python:
>
> > Thank-you very much for all the excellent replies. I'm thinking of using
> > this to determine if a sequence is a "run" (as in a card game). If I've
> > got a sorted hand [3, 4, 5, 6, 7], then I know I've got a 5-card run
>
>       A sorted list?
>
>       if (hand[-1] - hand[0]) == (len(hand) - 1)
>
> would seem to do it for your example.
>
>       Actually, if you KNOW the list is only 5 entries long
>
>       if (hand[4] - hand[0]) == 4
>

It's cute but wrong! How 'bout hand = [ 0, 0, 0, 4 ]? It's sorted,
passes your test and does not meet the OP's requirement :(

> would do it.
>
>       Or any equivalent... (hand[0] + 4) == hand[4]
>
>
> --
>  > ============================================================== <
>  >   [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >      [EMAIL PROTECTED]     |       Bestiaria Support Staff       <
>  > ============================================================== <
>  >           Home Page: <http://www.dm.net/~wulfraed/>            <
>  >        Overflow Page: <http://wlfraed.home.netcom.com/>        <

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to