NPR puzzle

Eric Chatonet eric.chatonet at sosmartsoftware.com
Wed Jul 20 17:20:29 EDT 2005


Hi again,

Right. This solution is not the dirtiest :-)
The reason is syntactic: the formulation gives up immediately if the  
first 2 chars do not match a symbol.

Le 20 juil. 05 à 23:12, Lynch, Jonathan a écrit :

> Funny...
>
> I guess quick and dirty was quickest - was it dirtiest?
>
> I might try playing with a switch control structure to see if that  
> is faster, but in the past I have found if-then to be a little faster.
>
>
> I tried conjoining the components of the if-then statements with a  
> bunch of 'or's and also by using 'and' with 'is in' instead of 'is  
> not in'...
>
> In both cases, it was like 2 or 3 milliseconds slower than the  
> spread-out version.
>
> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com [mailto:use- 
> revolution-bounces at lists.runrev.com] On Behalf Of Eric Chatonet
> Sent: Wednesday, July 20, 2005 5:08 PM
> To: How to use Revolution
> Subject: Re: NPR puzzle
>
> Hi Jonathan,
>
> You end up with my quick and dirty solution...
> Just a word: else is not necessary in this case since you run a next
> repeat if the condition is verified ;-)
>
> Le 20 juil. 05 à 22:48, Lynch, Jonathan a écrit :
>
>
>> I get a small increase in speed by abandoning the inner loop,  
>> allowing
>> the script to just go to the next word when there is not a match.  
>> I am
>> running a bunch of other programs on my computer right now, so my
>> speed
>> is compromised. Using Ro's script, I clocked at 75 milliseconds.
>> Modifying his script as shown below, I improved to 64 milliseconds:
>>
>> on mouseUp
>>   put the milliseconds into M
>>   put fld "W" into W
>>   put fld "E" into E
>>   repeat for each line L in W
>>     if char 1 to 2 of L is not in E then
>>       next repeat
>>     else if char 3 to 4 of L is not in E then
>>       next repeat
>>     else if char 5 to 6 of L is not in E then
>>       next repeat
>>     else if char 7 to 8 of L is not in E then
>>       next repeat
>>     else if char 9 to 10 of L is not in E then
>>       next repeat
>>     end if
>>     put L & linefeed after F
>>   end repeat
>>   put the milliseconds-M into field "computation time"
>>   put F into field "output"
>> end mouseUp


Best Regards from Paris,

Eric Chatonet.
----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        eric.chatonet at sosmartsoftware.com/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------




More information about the use-livecode mailing list