Hi all!

parE=: 4 : '(;"1[1<@({./)"0~(y=+/"1 o)#o=.>:((x$v)#:i.(v=.1+y-x)^x))<;.1[i.y'

par=: ([:(;"1)1<@({./)"0~]((=+/"1)#])([:>:[($#:i.@^~)1+-~))<;.1 i.@]


Modified tacit and explicit versions.


Cheers,


Erling Hellenäs


Den 2017-10-19 kl. 22:43, skrev Erling Hellenäs:
Hi all!

The idea here is to take all combinations of the possible number of elements in a bucket and the number of buckets, and then select the bucket combinations with the correct number of elements.

   par=: 4 : '(1,.2</\"1(i.x)#/~(y=+/"1 o)#o=.((x$v)#:i.v^x){1+i.v=.1+y-x)<;.1[1+i.y'
   2 par 3
┌───┬───┐
│1  │2 3│
├───┼───┤
│1 2│3  │
└───┴───┘
   2 par 4
┌─────┬─────┐
│1    │2 3 4│
├─────┼─────┤
│1 2  │3 4  │
├─────┼─────┤
│1 2 3│4    │
└─────┴─────┘
   2 par 5
┌───────┬───────┐
│1      │2 3 4 5│
├───────┼───────┤
│1 2    │3 4 5  │
├───────┼───────┤
│1 2 3  │4 5    │
├───────┼───────┤
│1 2 3 4│5      │
└───────┴───────┘
   3 par 4
┌───┬───┬───┐
│1  │2  │3 4│
├───┼───┼───┤
│1  │2 3│4  │
├───┼───┼───┤
│1 2│3  │4  │
└───┴───┴───┘
   3 par 5
┌─────┬─────┬─────┐
│1    │2    │3 4 5│
├─────┼─────┼─────┤
│1    │2 3  │4 5  │
├─────┼─────┼─────┤
│1    │2 3 4│5    │
├─────┼─────┼─────┤
│1 2  │3    │4 5  │
├─────┼─────┼─────┤
│1 2  │3 4  │5    │
├─────┼─────┼─────┤
│1 2 3│4    │5    │
└─────┴─────┴─────┘
   3 par 6
┌───────┬───────┬───────┐
│1      │2      │3 4 5 6│
├───────┼───────┼───────┤
│1      │2 3    │4 5 6  │
├───────┼───────┼───────┤
│1      │2 3 4  │5 6    │
├───────┼───────┼───────┤
│1      │2 3 4 5│6      │
├───────┼───────┼───────┤
│1 2    │3      │4 5 6  │
├───────┼───────┼───────┤
│1 2    │3 4    │5 6    │
├───────┼───────┼───────┤
│1 2    │3 4 5  │6      │
├───────┼───────┼───────┤
│1 2 3  │4      │5 6    │
├───────┼───────┼───────┤
│1 2 3  │4 5    │6      │
├───────┼───────┼───────┤
│1 2 3 4│5      │6      │
└───────┴───────┴───────┘

Cheers,

Erling Hellenäs

On 2017-10-19 20:54, Erling Hellenäs wrote:
Yes. Sorry. Thanks. /Erling

On 2017-10-19 19:47, Raul Miller wrote:
Most people will not have a C:/Users/erling/ directory.

Presumably, though, you are referring to x!y which counts x combinations of y.

http://www.jsoftware.com/help/dictionary/d410.htm

That's not quite what Skip was asking for, but it can be relevant in
an implementation.

Thanks,


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


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

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

Reply via email to