Created
July 1, 2020 19:32
-
-
Save adambene/271ce2d243c4f696b0f983554b99a10e to your computer and use it in GitHub Desktop.
Distinct items in list, naive implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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