Hi mark,
As I told it, I took this problem quick and dirty in five minutes.
For me, the challenge was only to know how many words among 3620
would match the formula :-)
So I used a very simple handler (running on a Mac G5 1.8 Mhz):
I blush with shame but here it is:
on mouseUp
put the milliseconds into tStart
put fld "Words" into tWords
put fld "Elements" into tElements
repeat for each line tLine in tWords
if char 1 to 2 of tLine is not among the lines of tElements then
next repeat
if char 3 to 4 of tLine is not among the lines of tElements then
next repeat
if char 5 to 6 of tLine is not among the lines of tElements then
next repeat
if char 7 to 8 of tLine is not among the lines of tElements then
next repeat
if char 9 to 10 of tLine is not among the lines of tElements
then next repeat
put tLine & cr after tRightList
end repeat
put the milliseconds - tStart
put tRightList into fld "Result"
end mouseUp
I think your code more optimised than mine :-)
Best Regards from Paris,
Eric Chatonet.
Le 20 juil. 05 à 19:46, Mark Wieder a écrit :
Eric-
Wednesday, July 20, 2005, 7:52:08 AM, you wrote:
How'd you manage to get 30 milliseconds run time? The best I can do is
about 130. Is your machine just that much faster than mine? Here's the
fastest code I could come up with - any suggestions on speeding it up?
on mouseUp
local tLine, tTestString
local x
local tBlnPossible
local tDictionary, tElements, tPossibles
local tTime
put "working..." into field "status"
put empty into field "possibles"
put the milliseconds into tTime
put field "dictionary" into tDictionary
put field "elements" into tElements
repeat for each line tLine in tDictionary
put true into tBlnPossible
repeat with x=1 to 9 step 2
put char x to x+1 of tLine into tTestString
if tTestString is not among the lines of tElements then
put false into tBlnPossible
exit repeat
end if
end repeat
if tBlnPossible then
put tLine & cr after tPossibles
end if
end repeat
put the milliseconds - tTime && "milliseconds" into field "elapsed"
put tPossibles into field "possibles"
put "found" && the number of lines in field "possibles" \
&& "possible answers" into field "status"
end mouseUp
----------------------------------------------------------------
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 [EMAIL PROTECTED]/
Phone 33 (0)1 43 31 77 62
Mobile 33 (0)6 20 74 50 86
----------------------------------------------------------------
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution