Yes, I had a bug in my previous definition for triplescount. Stupid. Should
have checked more before speaking.

But As I understand the problem, the numbers in each triple should be
unique. Looking at has several triples with duplicate numbers.

   t #~ 3=#&>t
+-----+-----+-----+-----+-----+-----+-----+-----+
|8 1 1|7 2 1|6 3 1|6 2 2|5 4 1|5 3 2|4 4 2|4 3 3|
+-----+-----+-----+-----+-----+-----+-----+-----+

The values (8 1 1; 6 2 2; 4 4 2; 4 3 3) are not unique leaving
   7 2 1; 6 3 1;5 4 1;5 3 2
+-----+-----+-----+-----+
|7 2 1|6 3 1|5 4 1|5 3 2|
+-----+-----+-----+-----+

which is what I get in the triples definition below. Same except the order
in each row is reversed.

   triples 10
1 2 7
1 3 6
1 4 5
2 3 5

I rewrote triplescount and made a triples as follows. This time I followed
my logic in my previous e-mail which I didn't in the definition of
triplescount then:

triples=:3 : 0
n1max=.<:<.y%3
n1=.>:i.n1max
n2max=.<:>.-:y-n1
n2=.n1+&.>(<@:>:@i.)"0 n2max-n1
n1n2=.;(<"0 n1),.&.>n2
n1n2,.y-+/"1 n1n2
)

triplescount=:3 : 0
n1max=.<:<.y%3
n1=.>:i.n1max
n2max=.<:>.-:y-n1
+/n2max-n1
)

   triples &.>6+i.10
+-----+-----+-----+-----+-----+-----+-----+------+------+------+
|1 2 3|1 2 4|1 2 5|1 2 6|1 2 7|1 2 8|1 2 9|1 2 10|1 2 11|1 2 12|
|     |     |1 3 4|1 3 5|1 3 6|1 3 7|1 3 8|1 3  9|1 3 10|1 3 11|
|     |     |     |2 3 4|1 4 5|1 4 6|1 4 7|1 4  8|1 4  9|1 4 10|
|     |     |     |     |2 3 5|2 3 6|1 5 6|1 5  7|1 5  8|1 5  9|
|     |     |     |     |     |2 4 5|2 3 7|2 3  8|1 6  7|1 6  8|
|     |     |     |     |     |     |2 4 6|2 4  7|2 3  9|2 3 10|
|     |     |     |     |     |     |3 4 5|2 5  6|2 4  8|2 4  9|
|     |     |     |     |     |     |     |3 4  6|2 5  7|2 5  8|
|     |     |     |     |     |     |     |      |3 4  7|2 6  7|
|     |     |     |     |     |     |     |      |3 5  6|3 4  8|
|     |     |     |     |     |     |     |      |      |3 5  7|
|     |     |     |     |     |     |     |      |      |4 5  6|
+-----+-----+-----+-----+-----+-----+-----+------+------+------+
   triplescount &>6+i.10
1 1 2 3 4 5 7 8 10 12
   (#@:triples) &>6+i.10
1 1 2 3 4 5 7 8 10 12

The results above look right. Please correct me if I'm wrong.

Below tried several triplescount's and see a pattern, but a little
different from what others are getting.

   triplescount"0] 10^>:i.7x
4 784 82834 8328334 833283334 83332833334 8333328333334

Well, this has been fun.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to