This seems to work:

parts=: (] #~ (%~ [EMAIL PROTECTED]) = +/"[EMAIL PROTECTED]) [: #:@i. 2&^&.<:
pieces=: [ ([EMAIL PROTECTED]@[ */ ]) parts
combos=:  (+"1/ #~ 0 = [: +/"1 *"1/)/@pieces

Example use:
   2 combos 6
   3 combos 6
   2 combos 8

I have not investigated the complexity of this approach.

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to