Apply one BPE merge to a token sequence: scan left to right and replace each occurrence of the adjacent pair pair by the concatenation of its two tokens. Merged occurrences do not overlap, so the earlier pair wins.
Implement solve(seq, pair).
Returns. Return a new list of tokens.
Example 1
Input:
solve(['a', 'b', 'a', 'b', 'c'], ('a', 'b'))
Output:
['ab', 'ab', 'c']
Example 2
Input:
solve(['a', 'a', 'a'], ('a', 'a'))
Output:
['aa', 'a']
No results yet
Run your code to check it against the examples, or submit to run every test.