No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Here is my try to [solve] the puzzle Heh, a fine example of Ken Thompson's adage "when in doubt, use brute force". Your code does have the merit of being very straightforward to understand. If I had the tuits I would code up an iterator solution using the closure-as-odometer idiom, but the code would not be as clear. A simple observation of your code is to note that many a time, the sum exceeds 100 way before you get down to the fifth inner loop. Therefore, exiting the loop early via last will save considerable amount of time:
You could unconditionally increment a counter in the inner loop inside this code and yours, and compare how many less times my inner loop gets called. - another intruder with the mooring of the heart of the Perl In reply to Re: How to generate restricted partitions of an integer
by grinder
|
|