NPR puzzle

Eric Chatonet eric.chatonet at sosmartsoftware.com
Fri Jul 22 02:01:53 EDT 2005


Hi Dick,

Kudos!

As Sarah pointed it out, I was surprised to find out that putting the  
fields into some variables first did not speed up the things as I  
would have thought.
Good to know.
Let us think array :-)

Le 21 juil. 05 à 23:19, Dick Kriesel a écrit :

> Here's a solution that takes 10 milliseconds on a 1GHz PowerBook G4.
>
> The main reason for the speed improvement over previous solutions  
> is that
> array look-ups are typically faster than string searches.
>
>   put the milliseconds into tMilliseconds
>   repeat for each line tSymbol in field 2
>     put "true" into tSymbolArray[tSymbol]
>   end repeat
>   repeat for each word tWord in field 1
>     if tSymbolArray[char 1 to 2 of tWord] then
>       if tSymbolArray[char 3 to 4 of tWord] then
>         if tSymbolArray[char 5 to 6 of tWord] then
>           if tSymbolArray[char 7 to 8 of tWord] then
>             if tSymbolArray[char 9 to 10 of tWord] then
>               put tWord & return after tHits
>             end if
>           end if
>         end if
>       end if
>     end if
>   end repeat
>   put the milliseconds - tMilliseconds \
>       into tElapsedMilliseconds
>   put number of lines in tHits && "hits in" \
>       && tElapsedMilliseconds && "milliseconds" \
>       & return & return & tHits

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