Skip to content

Instantly share code, notes, and snippets.

@sw1nn
Created September 24, 2024 13:45
Show Gist options
  • Save sw1nn/ea849019c4487f18e40b67bd19ba03b9 to your computer and use it in GitHub Desktop.
Save sw1nn/ea849019c4487f18e40b67bd19ba03b9 to your computer and use it in GitHub Desktop.

Remove consecutive duplicates

Write a function that takes a list of numbers and a limit, and returns a list where consecutive runs exceeding the limit have been removed entirely. Things to bear in mind:

- Non-consecutive duplicates are fine
- Consecutive duplicates exceeding the limit in the output are fine
- Memory and compute constraints (within reason) are not important, at least at first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment