Created
October 4, 2020 15:04
-
-
Save kurzweil777/e5b9e8152f3676adf0b57548d1cb53b0 to your computer and use it in GitHub Desktop.
Exercise from CodeWars
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
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