Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Unique Email Addresses by Tinus_Trotyl
def unique_emails(emails: list[str]) -> int:
adresses = set() # define a set for unique-addresses storage
for email in emails: # for all emails:
name, domain = email.lower().split('@') # ~ set to lowercase and split into name and domain
name = name.replace('.', '') # ~ remove dots from the name-part
if '+' in name: name = name[:name.index('+')] # ~ if any, chop off everything starting from '+'
adresses |= {'@'.join([name, domain])} # ~ compose address and to the addesses-set.
return len(adresses) # return the number of all unique-addresses found.
Nov. 25, 2021