a = [0,1,1,0,0,1,1,1,1,0,1,1,1,0]
b = [i for i in range(len(a))]
def get_usage_zone(action_type_list, tmstp_list):
insert_flag = False
calcu_start = False
earphone_pairs = []
earphone_pair = []
for i in range(len(action_type_list)):
if calcu_start == False:
if action_type_list[i] == 0:
continue
else:
calcu_start = True
if calcu_start == True:
if action_type_list[i] == 1:
insert_flag = True
if len(earphone_pair) == 0:
earphone_pair.append(tmstp_list[i])
else:
earphone_pair[0] = tmstp_list[i]
else:
if insert_flag == True:
earphone_pair.append(tmstp_list[i])
earphone_pairs.append(earphone_pair)
earphone_pair = []
insert_flag = False
return earphone_pairs
print(a)
print(b)
print(get_usage_zone(a, b))