It's still exponential due to the use of 2&^ . By exponential I mean exponential in time and/or space wrt to the size of the result. Of course the result is necessarily exponential wrt x and y.
A way to increase the reliability of the result is to apply some checks on it. e.g. ess_check=: 4 : 0 z=. x ess y assert. ($z) -: (x ness y),y assert. (i.#z) -: /:z assert. (i.x) -:"1 ~."1 z assert. ~:z ) ----- Original Message ----- From: Raul Miller <[EMAIL PROTECTED]> Date: Thursday, July 24, 2008 11:32 Subject: Re: [Jprogramming] equal-size partitions To: Programming forum <[email protected]> > Here's a version of my code which seems to be equivalent > to Roger Hui's code (which, unlike mine, can be relied on to > be correct): > > parts=: (] #~ (%~ [EMAIL PROTECTED]) = +/"[EMAIL PROTECTED]) [: #:@i. 2&^&.<: > pieces=: [ ([EMAIL PROTECTED]@[ */ ]) parts > combos=: (#~ ~."1 -:"1 /:[EMAIL PROTECTED]@{.)@(+"1/ #~&(,/) 0 = [: > +/"1 *"1/)/@pieces > cannon=: /:[EMAIL PROTECTED] > > 4 (cannon -: ess3) 12 > 1 > > Unfortunately, I still get a limit error for somewhat larger cases > 4 cannon 16 > |limit error > > Also, my approach seems only slightly faster (factor of 3 for the case > of the example I tested) which suggests that I have not done anything > useful about the underlying exponential growth problem. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
