Last active
April 29, 2021 11:35
-
-
Save JakeCowton/35f09d1403616c2e7a17f760a09c8965 to your computer and use it in GitHub Desktop.
Determine if a given list is a sublist of another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_sublist(a: list, b: list): | |
return any( | |
[v == a[0] and b[i:i + len(a)] == a for i, v in enumerate(b)] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment