Skip to content

Instantly share code, notes, and snippets.

@kurzweil777
Created October 4, 2020 15:04
Show Gist options
  • Save kurzweil777/e5b9e8152f3676adf0b57548d1cb53b0 to your computer and use it in GitHub Desktop.
Save kurzweil777/e5b9e8152f3676adf0b57548d1cb53b0 to your computer and use it in GitHub Desktop.
Exercise from CodeWars
from collections import Counter
def duplicate_count(text):
"""Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric
digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (
both uppercase and lowercase) and numeric digits. """
return sum([1 for a in Counter(text.lower()).values() if a > 1])
duplicate_count("abcde"), 0
duplicate_count("abcdea"), 1
duplicate_count("Indivisibilities"), 1
duplicate_count("abcdefghijklmnopqrstuvwxyz"), 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment