On 5/4/07, Brian Schott <[EMAIL PROTECTED]> wrote:
       Consider the following expression. For what values
of width, inc, and N do the following three properties of
partition hold?
a)      the cardinality (#) of partition = 4,
b)      #&, of each box of partition = width,
c)      the last atom in the last box of partition = N-1

I think you are describing a sequence of four boxes,
each of which contains width atoms, with the last
atom of each box held constant.

Without any other constraints, it seems to me that the
other atoms in these boxes could be picked randomly
and */ of the shape of any of these boxes needs to total
to width.

However, since you are calling this a partition, that
implies you have some input data that you are partitioning?
If so, this need not be solvable (since N-1 need not be
an atom in this data which is being partitioned.

Sample answer 1 with N = 400:

  (#,{:)&,each((1,inc ),:1,width) <;._3 ,: i. 400[inc =. 98[width=.106
+-------+-------+-------+-------+
|106 105|106 203|106 301|106 399|
+-------+-------+-------+-------+

Ok, here it looks like what you want is integers 0..N-1 broken up
into four groups, but I would not call this a partition (because, for
example, the index 98 appears in two different groups).

If indices can be repeated you have a huge variety of potential
solutions (depending on which indices you duplicate).  Also,
note that in this particular case you have applied a shape of 1 106
to the contents of each of the boxes, but 1 2 1 53 1 (for example)
would also be a viable shape.

Anyways, assuming that width does not exceed N, I think
this will at least do what you've specified:

part=:] (] - 0&>.@>:@-~&{:)L:0 [EMAIL PROTECTED] <"1@|:@:(+/) 0 1 2 3 * 4 
>[EMAIL PROTECTED] ]

       To be completely honest, I think I have a suitable
answer for my immediate needs, the solution above with N =
400, but I wonder if there is a general solution and problem
formulation.

Given the loose constraints, I think there are many general solutions,
some probably more concise than mine.

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

Reply via email to