Last active
July 1, 2020 19:04
-
-
Save adambene/3723992a4b43a29876accbf50908e501 to your computer and use it in GitHub Desktop.
Revisions
-
adambene revised this gist
Jul 1, 2020 . 2 changed files with 21 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +0,0 @@ This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ def distinct_naive_verbose(items): """ This naive and verbose implementation returns distinct elements of a list. """ results = list() # iterate through all items for item in items: member = False # linear search for the actual item in results for result in results: if item == result: member = True break # if we didn't find the item in results it is unique and we append to the results if not member: results.append(item) return results -
adambene revised this gist
Jul 1, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ def distinct_naive(items): results = list() for item in items: if not item in results: results.append(item) return results -
adambene created this gist
Jul 1, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ def distinct_naive(items): result = list() for item in items: if not item in result: result.append(item) return result