The task is
Given an array of ints, return True if the sequence.. 1, 3, 4 .. appears in the array somewhere.
def f(lst): | |
return any(lst[x:x + 3] == [1, 3, 4] for x in range(len(lst) - 2)) | |
# Another solution | |
def f(lst): | |
return (1, 3, 4) in zip(lst, lst[1:], lst[2:]) | |
assert f([6, 1, 3, 4, 2, 5]) | |
assert not f([5, 6, 1, 2, 3, 4]) |