Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re (tilly) 2: Add-A-Gram Performance

by runrig (Abbot)
on Feb 20, 2002 at 05:51 UTC ( [id://146507]=note: print w/replies, xml ) Need Help??


in reply to Re (tilly) 2: Add-A-Gram Performance
in thread Add-A-Gram Performance

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 :-)
(So if I run it on some new fangled 12Ghz system, it might break a minute,
right? ;-)

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 :-)

  • Comment on Re: Re (tilly) 2: Add-A-Gram Performance

Replies are listed 'Best First'.
Re (tilly) 4: Add-A-Gram Performance
by tilly (Archbishop) on Feb 20, 2002 at 11:20 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://146507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (None)
    As of 2024-04-18 23:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found