"be consistent" | |
PerlMonks |
Re: Re (tilly) 2: Add-A-Gram Performanceby runrig (Abbot) |
on Feb 20, 2002 at 05:51 UTC ( [id://146507]=note: print w/replies, xml ) | Need Help?? |
Hey, they still have the 9 9's problem that nobody has ruined yet.
Good luck getting it to run in under 1 minute. :-) Well, I got it running in about one hour (on my ancient 200MHz 486), which is better
than the few days I thought it was going to take at first :-)
What matters, of course, is how many iterations it takes, and what it came down to (in my solution) was how many ways to order the 4 operators eight in a row (4**8 => 65536), times how many ways to put 9 duplicate balls in eight different buckets (which is alot, until I realized each bucket only needs to hold at most two balls, and then I filtered most of the redundant and invalid combinations from that which resulted in only 64 combinations), which resulted in about 4 million iterations of the main loop. I'm not going to spoil the answer here (and I hope I haven't given away too much already, and only provoke "what the hell is he talking about?" responses from most people), since the add-a-gram has been done to death both here and on comp.lang.perl.misc, and I'd hate to see the same done to the 9 nines, but anyone that can filter the problem space even further has my ++'s...(hmm, wonder if I can get a job in Cambridge, MA now...) Update: Damn! While I took a completely different approach, it'll never beat tilly's (and I suppose its not even worth pointing out that my implementation was broken, and that the corrected version will take about 2 hours to run :-)
In Section
Seekers of Perl Wisdom
|
|