[Jprogramming] minmax differences
R.E. Boss
r.e.boss at planet.nl
Tue Aug 18 04:19:06 HKT 2009
5 mmd 10
+---------+---------+
|0 2 4 6 8|0 2 4 6 9|
|1 3 5 7 9|0 2 4 7 9|
| |0 2 5 7 9|
| |0 3 5 7 9|
+---------+---------+
k 5 comb 10 NB. match
0 2 4 6 9
0 2 4 7 9
0 2 5 7 9
0 3 5 7 9
5 mmd 12
+----------+----------+----------+----------+
|0 2 4 6 8|0 2 4 6 9|0 2 4 6 10|0 2 4 6 11|
|1 3 5 7 9|0 2 4 7 9|0 2 4 8 10|0 2 4 9 11|
|2 4 6 8 10|0 2 5 7 9|0 2 6 8 10|0 2 7 9 11|
|3 5 7 9 11|0 3 5 7 9|0 4 6 8 10|0 5 7 9 11|
| |0 2 4 7 10|0 2 4 7 11| |
| |0 2 5 7 10|0 2 5 7 11| |
| |0 3 5 7 10|0 3 5 7 11| |
| |1 3 5 7 10|1 3 5 7 11| |
| |0 2 5 8 10|0 2 4 8 11| |
| |0 3 5 8 10|0 2 6 8 11| |
| |1 3 5 8 10|0 4 6 8 11| |
| |0 3 6 8 10|0 2 5 9 11| |
| |1 3 6 8 10|0 3 5 9 11| |
| |1 4 6 8 10|1 3 5 9 11| |
| |0 2 5 8 11|0 2 6 9 11| |
| |0 3 5 8 11|0 4 6 9 11| |
| |1 3 5 8 11|0 3 7 9 11| |
| |0 3 6 8 11|1 3 7 9 11| |
| |1 3 6 8 11|0 4 7 9 11| |
| |1 4 6 8 11|1 5 7 9 11| |
| |2 4 6 8 11| | |
| |0 3 6 9 11| | |
| |1 3 6 9 11| | |
| |1 4 6 9 11| | |
| |2 4 6 9 11| | |
| |1 4 7 9 11| | |
| |2 4 7 9 11| | |
| |2 5 7 9 11| | |
+----------+----------+----------+----------+
k 5 comb 12 NB. no match; second box
0 2 5 8 11
0 3 5 8 11
0 3 6 8 11
0 3 6 9 11
For mmd, see
http://jsoftware.com/pipermail/programming/2009-August/015925.html
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: programming-bounces at jsoftware.com [mailto:programming-
> bounces at jsoftware.com] Namens John Randall
> Verzonden: maandag 17 augustus 2009 21:23
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] minmax differences
>
> 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
More information about the Programming
mailing list