You are viewing a single comment's thread. Return to all comments →
def minimumDistances(a): lenDict = {} for idx,el in enumerate(a): if a.count(el) == 1: continue if el not in lenDict: lenDict[el] = [idx] else: lenDict[el].append(idx) dif = -1 for key, value in lenDict.items(): for i in range(1,len(value)): dif_val = value[i] - value[i-1] if dif == -1: dif = dif_val if dif_val< dif: dif = dif_val if dif == 1: break return dif
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Distances
You are viewing a single comment's thread. Return to all comments →