Message Boards Message Boards

0
|
23 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to specify incremental constraint in LongestOrderedSequence?

Posted 7 hours ago

I'm looking for the longest ordered subsequences of integer pairs with specific incremental constraints. In these examples, I'd like the last value of each pair to be 1 less than the first value of the next pair. So far I've not discovered what pattern to specify.

Example 1.

LongestOrderedSequence[{{4, 5}, {7, 8}, {11, 12}, {13, 14}, {15, 16},
{65, 66}}, (#2[[1]] - #1[[2]] == 1) &]

{{4, 5}}

I was hoping for

{{11, 12}, {13, 14}, {15, 16}}

Example 2.

LongestOrderedSequence[{{2, 4}, {6, 8}, {9, 11}, {12, 14},
{98, 100}}, (#2[[1]] - #1[[2]] == 1) &]

{{2, 4}}

I was hoping for

{{6, 8}, {9, 11}, {12, 14}}
POSTED BY: Richard Frost
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract