Skip to content

Instantly share code, notes, and snippets.

@adambene
Created July 1, 2020 19:32
Show Gist options
  • Save adambene/271ce2d243c4f696b0f983554b99a10e to your computer and use it in GitHub Desktop.
Save adambene/271ce2d243c4f696b0f983554b99a10e to your computer and use it in GitHub Desktop.
Distinct items in list, naive implementation
def distinct_naive(items):
"""
This naive implementation returns distinct elements of a list.
"""
results = list()
# iterate through all items
for item in items:
# append item to results if not member yet
if not item in results:
results.append(item)
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment