[Jprogramming] minmax differences
John Randall
randall at andromeda.rutgers.edu
Tue Aug 18 03:23:13 HKT 2009
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
More information about the Programming
mailing list