1234567891011121314151617181920212223242526272829303132333435363738 |
- import data
- def count_have_location(l):
- ans = 0
- for d in l:
- if data.have_location(d):
- ans += 1
- return ans
- def list_have_continue_maybe_indoor(l):
- last_indoor = False
- for d in l:
- indoor = data.maybe_indoor(d)
- if indoor and last_indoor:
- return True
- last_indoor = indoor
- return False
- def check_entry(before, curr, after):
- if not data.have_location(curr):
- return None
- if count_have_location(before) < 9:
- return None
- if not data.maybe_entry(curr):
- return None
- if data.maybe_entry(before[-1]):
- return None
- if not list_have_continue_maybe_indoor(after):
- return None
- return before[-1]
- def recognize_entries(l):
- ret = []
- for i in range(59, len(l) - 12):
- x = check_entry(l[i-59:i], l[i], l[i+1:i+13])
- if not x is None:
- ret.append(x)
- return ret
|