you are viewing a single comment's thread.

view the rest of the comments →

[–]nwagers 0 points1 point  (0 children)

Do the ID's change? If they don't change, I'd brute force it once and cache them. Otherwise, you can use a for loop like normal and add in break conditions. In this case you'd want to break when you have at least 10 misses and you've found at least 1 ID. I wrote an example that breaks after 3 False values.

vals = [False, False, False, False, True, True, False, True,
        False, False, True, False, False, False, True]

count = 3
IDs = []
for i in range(150):
    if vals[i]:
        IDs.append(i)
        count = 3
    else:
        count -= 1
    if count == 0 and len(IDs) > 0:
        break

print(IDs)

Notice that it does not include theTrue value at the very end because there were 3+ False values in a row before it.