I worked on this further over the weekend. I'll post again after I've formatted everything, but the result now handles any number of cubes from 3 to 26, although anything more than about 14 will probably be too slow. For 4 cube puzzles the new code is about four times faster than my old code. For 12 cube puzzles it's >100 times faster. I came up with a nice short cut.
On Sun, Apr 14, 2013 at 4:58 PM, Alex Tweedly <[email protected]> wrote: > > Yes, a few interesting aspects. > > I too was surprised that the (intuitive) array method was slower than the > string-based method, so I looked into it some more. > > The string method took 35-37 msec on my machine. > The array method took 84-85 msecs. > > But i realized that as well as changin string -> array, you had > effectively changed from column-first to row-first processing, and > row-first means you have a larger initial time before you can get a > duplicate. I changed the array method to be column-first, which decreased > the time to 54-56 msecs -- still much slower. > > But of course, if you do it in column order, there is no need to use an > array, so I switched to s scalar variable, and decreased the time to 29-32 > msecs; roughly 15% improvement. Thereby showing that "contains" is > marginally faster than "replace ... with empty". Hmmm - no real surprise :-( > > Other observation is that in the "optimized" version, we already know > there are no duplicates in the existing lines - only the last line can > possibly duplicate with an earlier one. So you can modify "checkit" to use > that fact, and get the time down to 24-25 msecs. > > Let's see that gave me twenty minutes of fun coding to save 12 millisecs. > Just as well I enjoyed it, because the time saving didn't justify the > effort. > > -- Alex. > > > > On 12/04/2013 16:34, Geoff Canyon wrote: > >> http://gcanyon.wordpress.com/**2013/04/12/brute-force-**insanity/<http://gcanyon.wordpress.com/2013/04/12/brute-force-insanity/> >> >> I posted my answer, so don't scroll down if you want to try yourself. >> There >> were some interesting aspects to the code. >> >> gc >> ______________________________**_________________ >> use-livecode mailing list >> [email protected] >> Please visit this url to subscribe, unsubscribe and manage your >> subscription preferences: >> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode> >> > > > ______________________________**_________________ > use-livecode mailing list > [email protected] > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode> > _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
