NPR puzzle

Lynch, Jonathan bnz2 at cdc.gov
Thu Jul 21 09:33:18 EDT 2005


When I tried conjoining the if-then statement like that, both with 'or'
and with 'and' I found it to be 2 to 3 milliseconds slower than separate
if-then statements.

-----Original Message-----
From: use-revolution-bounces at lists.runrev.com
[mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Jim Hurley
Sent: Wednesday, July 20, 2005 6:43 PM
To: use-revolution at lists.runrev.com
Subject: Re: NPR puzzle

>
>Message: 10
>Date: Wed, 20 Jul 2005 14:52:50 -0500
>From: "Glenn E. Fisher" <gefisher at mac.com>
>Subject: Re: NPR puzzle
>To: How to use Revolution <use-revolution at lists.runrev.com>
>Message-ID: <8425930f6dbe22c95c747155f706c649 at mac.com>
>Content-Type: text/plain;	charset=US-ASCII;	format=flowed
>
>Jim,
>
>Here is my submission that ran in 70 milliseconds on my 5 1/2 year old
>G4 450 MHz tower:
>
>    set cursor to watch
>    put the milliseconds into t
>    put fld "ChemSymbols" into c
>    put fld "dictionary" into d
>    repeat for each line L in d
>      if c contains char 1 to 2 of L and c contains char 3 to 4 of L\
>      and c contains char 5 to 6 of L and c contains char 7 to 8 of L\
>      and c contains char 9 to 10 of L then
>        put L & CR after o
>      end if
>    end repeat
>    put the milliseconds -t into t
>    put o into fld "Output"
>    put "time=" & t && "msecs" after fld "Output"
>
>Cheers,
>Glenn


Glenn,

Great solution!

At first I thought it would be slower than the one that most of us 
opted for, i.e. test each condition sequentially and if the test 
fails at any level go on with a "next repeat".

I thought RR would test all the conditionals in your handler (in 
...and ... and...) before moving on to the next repeat, but Scott 
Raney was too smart for that. Apparently, at the point where the 
"and" test fails, RR  decides there is no point in proceeding with 
the others, so...... next repeat.

The speed is about the same for either method.

Jim

P.S. If you submit your solution to NPR and your name is drawm, you 
are in danger of being called on Sunday for another test of wits. My 
mind works too slowly for this kind of exposure.


_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list