Skip to content

Instantly share code, notes, and snippets.

@zeapo
Created May 29, 2017 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeapo/2229fddf79d6ed912c4f223eec7d9733 to your computer and use it in GitHub Desktop.
Save zeapo/2229fddf79d6ed912c4f223eec7d9733 to your computer and use it in GitHub Desktop.
null created by zeapo - https://repl.it/IW9F/0
def fn(arr):
target = [1, 3, 4]
j = 0
for el in arr:
if el == target[j]:
j += 1
else:
j = 0
if j == len(target):
return True
return False
assert fn([0, 1, 2, 1, 3, 4, 5]) == True
assert fn([1, 3, 4]) == True
assert fn([1, 3]) == False
assert fn([]) == False
assert fn([1, 3, 5]) == False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment