Skip to content
Astera Technology

Specify whether a pattern must be consecutive

Distinguish adjacent matching from a merely ordered subsequence.

Compare the rule with concrete cases

Fictional search requires A immediately followed by B. A,B matches; A,X,B does not. An alternative ordered-subsequence rule would allow the middle X. Both rules preserve order, so saying “find A before B” is insufficient for the consecutive requirement.

Filled synthetic modelling cases
SequenceAdjacent A,BA-before-B subsequenceWhy
A,BYesYesNo intervening item
A,X,BNoYesX interrupts adjacency
B,ANoNoOrder reversed
Download editable CSV ↓

Work through the distinction

The intervening X distinguishes adjacency from order alone. Surrounding X items distinguish matching a portion from requiring whole-sequence equality. Include both contrasts in the cases.

Does X,A,B,X match the original consecutive rule?

Show the worked answer

Yes. Its middle A,B are adjacent. The rule does not require the whole sequence to equal only A,B.

Acceptance wording to adapt

Return a match when some adjacent pair of positions contains A then B. Allow other items before or after that pair. Reject A,X,B as a match for this pattern.

Related resources