(first_list, second_list,offset,max_difference)
return matches
Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim 
    to find the closest match for every input tuple.
    
    Input:
    first_list -- first dictionary of (stamp,data) tuples
    second_list -- second dictionary of (stamp,data) tuples
    offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
    max_difference -- search radius for candidate generation

    Output:
    matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))
Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim 
    to find the closest match for every input tuple.
    
    Input:
    first_list -- first dictionary of (stamp,data) tuples
    second_list -- second dictionary of (stamp,data) tuples
    offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
    max_difference -- search radius for candidate generation
Associate two dictionaries of ( stamp data ) . As the time stamps never match exactly we aim to find the closest match for every input tuple . Input : first_list -- first dictionary of ( stamp data ) tuples second_list -- second dictionary of ( stamp data ) tuples offset -- time offset between both dictionaries ( e . g . to model the delay between the sensors ) max_difference -- search radius for candidate generation
def associate(first_list, second_list,offset,max_difference):
    """
    Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim 
    to find the closest match for every input tuple.
    
    Input:
    first_list -- first dictionary of (stamp,data) tuples
    second_list -- second dictionary of (stamp,data) tuples
    offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
    max_difference -- search radius for candidate generation

    Output:
    matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))
    
    """
    first_keys = list(first_list.keys())
    second_keys = list(second_list.keys())
    potential_matches = [(abs(a - (b + offset)), a, b) 
                         for a in first_keys 
                         for b in second_keys 
                         if abs(a - (b + offset)) < max_difference]
    potential_matches.sort()
    matches = []
    for diff, a, b in potential_matches:
        if a in first_keys and b in second_keys:
            first_keys.remove(a)
            second_keys.remove(b)
            matches.append((a, b))
    
    matches.sort()
    return matches
def associate ( first_list , second_list , offset , max_difference ) : first_keys = list ( first_list . keys ( ) ) second_keys = list ( second_list . keys ( ) ) potential_matches = [ ( abs ( a - ( b + offset ) ) , a , b ) for a in first_keys for b in second_keys if abs ( a - ( b + offset ) ) < max_difference ] potential_matches . sort ( ) matches = [ ] for diff , a , b in potential_matches : if a in first_keys and b in second_keys : first_keys . remove ( a ) second_keys . remove ( b ) matches . append ( ( a , b ) ) matches . sort ( ) return matches