+--------+------+----+-----------+---------+---------+-----+-----+-----+----+-----+-----+-----+-------+-------+-------+--------+--------+-----+-----+ |24 26 28|28 6 5|5 28|28 16 16 |16 16 26 |26 19 3 2|2 13 |13 11|11 19|19 2|2 27 |27 10|10 19|19 5 |5 17 27|27 19 7|7 24 28 |28 27 14|14 22|22 21| +--------+------+----+-----------+---------+---------+-----+-----+-----+----+-----+-----+-----+-------+-------+-------+--------+--------+-----+-----+ |24 26 28|28 6 5|5 28|28 16 16 26|26 19 3 2|2 13 |13 11|11 19|19 2 |2 27|27 10|10 19|19 5 |5 17 27|27 19 7|7 24 28|28 27 14|14 22 |22 21| | +--------+------+----+-----------+---------+---------+-----+-----+-----+----+-----+-----+-----+-------+-------+-------+--------+--------+-----+-----+
The first line comes from my last testcase, the last line is your (first) f-solution. Your fourth block is neither up nor down (or both). R.E. Boss -----Original Message----- From: Programming <programming-boun...@forums.jsoftware.com> On Behalf Of xash Sent: donderdag 20 mei 2021 13:49 To: programm...@jsoftware.com Subject: Re: [Jprogramming] ups & downs f=:((#~ 1&|.) ,&.> <;.1~) 0 1, 0= 2+/\ }: (<+_1*>) }. The first part assigns _1 to elements that are greater than the next one, and 1 to elements that are less than the next one. Where _1 1 or 1 _1 occur, a new group starts. Thus 0= 2+/\. This gets us the starting indices for <;.1. Because the borders should be included, we prepend each element that is before a group start `(#~ 1&|.)` to that group `,&.>` (thus the unusual `0 1,` for the group starts). ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm