diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json index 3f14fbba7..35c7a4ad5 100644 --- a/snippet_data/snippetList.json +++ b/snippet_data/snippetList.json @@ -482,14 +482,14 @@ "type": "snippetListing", "title": "filter_non_unique", "attributes": { - "text": "Filters out the non-unique values in a list.\n\nUse a `Counter` to get the count of each value in the list.\nUse list comprehension to create a list containing only the unique values.\n\n", + "text": "Filters out the non-unique values in a list.\n\nUse a `collections.Counter` to get the count of each value in the list.\nUse list comprehension to create a list containing only the unique values.\n\n", "tags": [ "list", "beginner" ] }, "meta": { - "hash": "cc048906b1a368428244af8202aeb3a60b1b7b7bf52ad744e92d3e21f6be95f2" + "hash": "fc7c8b72dd9c4f53cd5d8ffe4c2befd0f1a6807caf58c0a2ddced195c6fa6c4f" } }, { @@ -497,14 +497,30 @@ "type": "snippetListing", "title": "filter_unique", "attributes": { - "text": "Filters out the unique values in a list.\n\nUse a `Counter` to get the count of each value in the list.\nUse list comprehension to create a list containing only the non-unique values.\n\n", + "text": "Filters out the unique values in a list.\n\nUse a `collections.Counter` to get the count of each value in the list.\nUse list comprehension to create a list containing only the non-unique values.\n\n", "tags": [ "list", "beginner" ] }, "meta": { - "hash": "f3e5cada914ae863ca9cf8fd8780b1634ea526d78f1f542c5c7577f6dd685cfc" + "hash": "d5680d2e4f63df60dbf4cef97de86a6e0aee70284aa2729ae69427e8231521e0" + } + }, + { + "id": "find_parity_outliers", + "type": "snippetListing", + "title": "find_parity_outliers", + "attributes": { + "text": "Given a list, returns the items that are parity outliers.\n\nUse `collections.Counter` with a list comprehension to count even and odd values in the list, use `collections.Counter.most_common()` to get the most common parity.\nUse a list comprehension to find all elements that do not match the most common parity.\n\n", + "tags": [ + "list", + "math", + "intermediate" + ] + }, + "meta": { + "hash": "87bee9709b95c43c36718bc31f6f3c381c05159b7d33e0016ede29d4168d3843" } }, { diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json index c6dda92de..86724de73 100644 --- a/snippet_data/snippets.json +++ b/snippet_data/snippets.json @@ -762,7 +762,7 @@ "type": "snippet", "attributes": { "fileName": "filter_non_unique.md", - "text": "Filters out the non-unique values in a list.\n\nUse a `Counter` to get the count of each value in the list.\nUse list comprehension to create a list containing only the unique values.\n\n", + "text": "Filters out the non-unique values in a list.\n\nUse a `collections.Counter` to get the count of each value in the list.\nUse list comprehension to create a list containing only the unique values.\n\n", "codeBlocks": { "code": "from collections import Counter\n\ndef filter_non_unique(lst):\n return [item for item, count in counter = Counter(lst).items() if count == 1]", "example": "filter_non_unique([1, 2, 2, 3, 4, 4, 5]) # [1, 3, 5]" @@ -773,11 +773,11 @@ ] }, "meta": { - "hash": "cc048906b1a368428244af8202aeb3a60b1b7b7bf52ad744e92d3e21f6be95f2", + "hash": "fc7c8b72dd9c4f53cd5d8ffe4c2befd0f1a6807caf58c0a2ddced195c6fa6c4f", "firstSeen": "1566296031", - "lastUpdated": "1578227946", - "updateCount": 4, - "authorCount": 3 + "lastUpdated": "1578502657", + "updateCount": 5, + "authorCount": 4 } }, { @@ -786,7 +786,7 @@ "type": "snippet", "attributes": { "fileName": "filter_unique.md", - "text": "Filters out the unique values in a list.\n\nUse a `Counter` to get the count of each value in the list.\nUse list comprehension to create a list containing only the non-unique values.\n\n", + "text": "Filters out the unique values in a list.\n\nUse a `collections.Counter` to get the count of each value in the list.\nUse list comprehension to create a list containing only the non-unique values.\n\n", "codeBlocks": { "code": "from collections import Counter\n\ndef filter_unique(lst):\n return [item for item, count in Counter(lst).items() if count > 1]", "example": "filter_unique([1, 2, 2, 3, 4, 4, 5]) # [2, 4]" @@ -797,11 +797,36 @@ ] }, "meta": { - "hash": "f3e5cada914ae863ca9cf8fd8780b1634ea526d78f1f542c5c7577f6dd685cfc", + "hash": "d5680d2e4f63df60dbf4cef97de86a6e0aee70284aa2729ae69427e8231521e0", "firstSeen": "1570035984", - "lastUpdated": "1578227961", - "updateCount": 7, - "authorCount": 4 + "lastUpdated": "1578502673", + "updateCount": 8, + "authorCount": 5 + } + }, + { + "id": "find_parity_outliers", + "title": "find_parity_outliers", + "type": "snippet", + "attributes": { + "fileName": "find_parity_outliers.md", + "text": "Given a list, returns the items that are parity outliers.\n\nUse `collections.Counter` with a list comprehension to count even and odd values in the list, use `collections.Counter.most_common()` to get the most common parity.\nUse a list comprehension to find all elements that do not match the most common parity.\n\n", + "codeBlocks": { + "code": "from collections import Counter\n\ndef find_parity_outliers(nums):\n return [\n x for x in nums\n if x % 2 != Counter([n % 2 for n in nums]).most_common()[0][0]\n ]", + "example": "find_parity_outliers([1, 2, 3, 4, 6]) # [1, 3]" + }, + "tags": [ + "list", + "math", + "intermediate" + ] + }, + "meta": { + "hash": "87bee9709b95c43c36718bc31f6f3c381c05159b7d33e0016ede29d4168d3843", + "firstSeen": "1578502475", + "lastUpdated": "1578502475", + "updateCount": 2, + "authorCount": 2 } }, {