Flavel Steve wrote:
if c is in char i+1 to -i of tNum then
[Mark - nope - should have been ".... i+1 to -1 of tNum" in both cases.
Alex
My solution looked at all the permutations and took around 900 ms
One suggestion to improve your very elegant solution
--repeat while tNum mod c <>0
subtract tNum mod c from tNum
--end repeat
No need for the repeat loop. With this refinement I get it in around
12 ms
You're right. My second attempt (sent late last night) did a variant of
that (taking it one step further and used the "lowest common multiple of
all digits considered so far" as the step value). Hence < 1 ms time.
I guess the end result of applying these techniques would be to analyze
it completely, resulting in the following program
on mouseUp
put "9867312" into msg
-- can't have a 5 because ....
-- can't have a 4 because ....
-- can't be > .... because of need to reduce to 0 mod 7
-- must be ....
-- and more complete analysis until all the programming fun has
gone out of it.
end mouseUp
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.361 / Virus Database: 267.12.5/149 - Release Date: 25/10/2005
_______________________________________________
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