Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def spy_game(nums):
- # Any sequence
- sequence = [0, 0, 7]
- # List of booleans indicating, whether current number in sequence was found
- matches = [False for i in range(len(sequence))]
- # Index of current element in sequence to check
- current_idx = 0
- # Current element in sequence to check
- next_to_check = sequence[current_idx]
- # Iterate over nums
- for i in range(0, len(nums)):
- # If current number matches currently checked number in sequence
- if nums[i] == next_to_check:
- # Mark it as True
- matches[current_idx] = True
- # Go to next one unless it's over :(
- current_idx += 1
- if current_idx == len(sequence):
- break
- next_to_check = sequence[current_idx]
- # If current number does not match next to check
- elif nums[i] not in sequence:
- pass
- return all(item == True for item in matches)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement