isums=: 4 : 0 if. 0>:y do. i.0 0 elseif. 1= y do. x $~ (0<x),1 elseif. 1 do. j=. 1+i.9 ((-: ~.)"1 # ]) ; j ,.&.> (x-j) isums&.> y-1 end. )
5 isums 3 $5 isums 3 0 3 6 isums 3 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 7 isums 3 1 2 4 1 4 2 2 1 4 2 4 1 4 1 2 4 2 1 I am not sure that this is a good way to solve Kakuro puzzles. ----- Original Message ----- From: JC Coez <[EMAIL PROTECTED]> Date: Friday, July 28, 2006 7:26 am Subject: Re: [Jprogramming] Diagonal generalization > > > > Perhaps you might like to refine your question. The indicies of > each > > element are generated by > > > > ind =: $ #: [: i. [:*/$ > > > To refine my question : given an integer X and a number n, I would > like to > find all combinations of n different integers from 1 to 9 for > which the sum > is N. Just like in the kakuro puzzle. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
