I don't know whether this is a puzzle for anyone
else, but it is for me. Two sample answers are given below,
but I am looking for an algorithm and maybe constraints on
the domain of the problem. By constraints I mean for example
that for some values of N there may be no feasible solution.

        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

        (A possible additional criterion is to find the
solution which uses the maximum inc and minimum width, if
there is not a unique solution.)

partition =. ((1,inc ),:1,width) <;._3 ,: i. N

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|
+-------+-------+-------+-------+

Sample answer 2 with N = 38:

   (#,{:)&,each((1,inc ),:1,width) <;._3 ,: i. 38[inc =. 8[width=.14
+-----+-----+-----+-----+
|14 13|14 21|14 29|14 37|
+-----+-----+-----+-----+

        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.


(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to