Parallel arithmetic?

jburgy jburgy at gmail.com
Fri Aug 5 07:53:34 EDT 2005


Dennis Lee Bieber wrote:
> On Thu, 04 Aug 2005 20:59:33 -0500, "Terrance N. Phillip"
> <mediocre_person at hotmail.com> 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]
>
>
> --
>  > ============================================================== <
>  >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >      wulfraed at dm.net     |       Bestiaria Support Staff       <
>  > ============================================================== <
>  >           Home Page: <http://www.dm.net/~wulfraed/>            <
>  >        Overflow Page: <http://wlfraed.home.netcom.com/>        <




More information about the Python-list mailing list