Skip to content

@KevinEtienne /find_duplicate.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
find duplicate
def find_duplicate(seq):
# holds our duplicate list
duplicate_bucket = []
# helps to identify a duplicate
seen_bucket = set()
for item in (seq):
if item not in seen_bucket:
seen_bucket.add(item)
else:
duplicate_bucket.append(item)
return duplicate_bucket
def find_dup(counter, next_element, seen_bucket, bucket):
"""
recursive function to find duplicate
based on a generator
"""
el = next_element.next().group()
if el not in seen_bucket:
seen_bucket.add(el)
else:
bucket.append(el)
counter -= 1
if counter > 0:
return find_dup(counter, next_element, seen_bucket, bucket)
return seen_bucket, bucket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.