Raul Miller wrote:
> require 'stats'
>
> Given a result from comb pick the entries which
> maximize the minimum difference between
> any two adjacent entries.
>

Raul, could you give some more examples of expected results?

My solution

sdiff=:(/:~"1 )@:( 2 -~/\"1 ])
k=:((] -:"1 {.@:\:~)@: sdiff) # ]

gives the correct result

   k 3 comb 8
0 3 7
0 4 7

on the example data.

My approach is to sort the differences for each combination, pick the
lexicographically greatest, and use this to select combinations.  Will
this do the trick, or am I misunderstanding the problem?

Best wishes,

John


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

Reply via email to