Perhaps June Kim could refine his specification of requirements.
He expressed content with my flawed offering which purported to
minimise fret-size deviation, but RE Boss demurred.
A partition such as 0 1; 2 3; 4 5; 6 7 8 9 10 looks ok, but
when we get to K=501 and N=1001, say, the result looks rather
bizarre, and a smaller spread of fret-sizes might be preferred.
If so, Ewart's elegant contribution is a worthy winner.
If not, then my earlier phrase,
a =: ((>./\@([ {. <[EMAIL PROTECTED] # [EMAIL PROTECTED])~ #) </. ])
or this more compact variant
b =: ((+/\@(] {. [ # <[EMAIL PROTECTED]) #) </. ])
or RE Boss's preferred version of a
c =: (((<:@[ <. <[EMAIL PROTECTED] <[EMAIL PROTECTED] [EMAIL PROTECTED]) #)
</. ])
all seem reasonable solutions, but none as elegant as "cutup".
Surprisingly, a and b are somewhat faster than c for some
arguments, despite their use of {. and scan.
Mike
R.E. Boss wrote:
As far as I understood the original problem, one should have <:K segments of
length <.N%K and the last segment with the rest.
4 cutup i.11
+-----+-----+-----+----+
|0 1 2|3 4 5|6 7 8|9 10|
+-----+-----+-----+----+
contrast to
4 (((<:@[ <. <[EMAIL PROTECTED] <[EMAIL PROTECTED] [EMAIL PROTECTED]) #) </. ])i.11
+---+---+---+----------+
|0 1|2 3|4 5|6 7 8 9 10|
+---+---+---+----------+
What's more
4 cutup i.10
+-----+---+-----+---+
|0 1 2|3 4|5 6 7|8 9|
+-----+---+-----+---+
So your cutup solves the variant brought up by Day "reducing the deviation
of fret-sizes".
R.E. Boss
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Ewart Shaw
Verzonden: donderdag 16 november 2006 17:09
Aan: Programming forum
Onderwerp: RE: [Jprogramming] Re: Coding Problem
I may have misunderstood the problem, or missed the solution,
but doesn't the following do what's required?
cutup=: <.@(* (i. % ])@#) </. ]
4 cutup i. 11
+-----+-----+-----+----+
|0 1 2|3 4 5|6 7 8|9 10|
+-----+-----+-----+----+
J.E.H.Shaw [Ewart Shaw] [EMAIL PROTECTED] TEL: +44 2476 523069
Department of Statistics, University of Warwick, Coventry CV4 7AL, UK
http://www.warwick.ac.uk/statsdept http://www.ewartshaw.co.uk
Will read usenet posts up to the first insult (which may be in the Subject)
----------------------------------------------------------------------
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