Demo entry 6637508

py

   

Submitted by a on Sep 03, 2017 at 08:12
Language: Python. Code size: 2.7 kB.

import copy
def compare_list(a,b):
    i = 0
    # time1=time.time()
    for j in xrange(len(b)):
        temp1 = b[i]
        temp0 = a[j]
        if (temp1[0] == temp0[0]) and (temp1[1] == temp0[1]) and (temp1[2] == temp0[2]) and (temp1[3] == temp0[3]):
            i = i + 1
        else:
            continue
    if i != 31:
        tmp = copy.deepcopy(b[i:])
        return tmp
    else:
        return 0

def renew_time(d):
    for i in d:
        # print i[0]
        str_time='13:41:'
        # if len(i[0])==5:
        #     i[0]=i[0]+':00'
        #     str_time=i[0][0:5]+':'
        # else:
        i[0]=str_time+i[0]
    # print first_im_li
    return d
a=[['20', '47.76', 'green', '1'], ['25', '47.76', 'green', '1'], ['49', '47.77', 'red', '2'], ['49', '47.77', 'red', '1'], ['49', '47.77', 'red', '1'], ['49', '47.77', 'red', '2'], ['49', '47.77', 'red', '1'], ['49', '47.77', 'red', '2'], ['49', '47.77', 'red', '10'], ['50', '47.77', 'green', '2'], ['51', '47.77', 'green', '1'], ['54', '47.78', 'red', '3'], ['56', '47.77', 'green', '1'], ['57', '47.78', 'red', '38'], ['13:40', '47.77', 'green', '2'], ['00', '47.77', 'green', '1'], ['03', '47.77', 'green', '1'], ['05', '47.77', 'green', '1'], ['10', '47.77', 'green', '1'], ['15', '47.77', 'green', '1'], ['20', '47.77', 'green', '1'], ['23', '47.77', 'green', '1'], ['27', '47.77', 'green', '1'], ['47', '47.77', 'green', '1'], ['13:41', '47.77', 'green', '1'], ['02', '47.77', 'green', '1'], ['02', '47.77', 'green', '1'], ['02', '47.77', 'red', '2'], ['04', '47.77', 'red', '18'], ['14', '47.77', 'green', '1'], ['15', '47.78', 'red', '1']]
# str_time=None
b=[['49', '47.77', 'red', '2'], ['49', '47.77', 'red', '1'], ['49', '47.77', 'red', '1'], ['49', '47.77', 'red', '2'], ['49', '47.77', 'red', '1'], ['49', '47.77', 'red', '2'], ['49', '47.77', 'red', '10'], ['50', '47.77', 'green', '2'], ['51', '47.77', 'green', '1'], ['54', '47.78', 'red', '3'], ['56', '47.77', 'green', '1'], ['57', '47.78', 'red', '38'], ['13:40', '47.77', 'green', '2'], ['00', '47.77', 'green', '1'], ['03', '47.77', 'green', '1'], ['05', '47.77', 'green', '1'], ['10', '47.77', 'green', '1'], ['15', '47.77', 'green', '1'], ['20', '47.77', 'green', '1'], ['23', '47.77', 'green', '1'], ['27', '47.77', 'green', '1'], ['47', '47.77', 'green', '1'], ['13:41', '47.77', 'green', '1'], ['02', '47.77', 'green', '1'], ['02', '47.77', 'green', '1'], ['02', '47.77', 'red', '2'], ['04', '47.77', 'red', '18'], ['14', '47.77', 'green', '1'], ['15', '47.78', 'red', '1'], ['26', '47.77', 'green', '1'], ['26', '47.77', 'green', '9']]
c=compare_list(a,b)
a=b
print a
d=renew_time(c)
print d
print a

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).