Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
regexp & set solution in Clear category for Unique Email Addresses by perimeter
def unique_emails(emails: list[int]) -> int:
# your code here
import re
addresses = { re.sub( '\.(?=.*@)',
'',
re.sub( '\+.*@',
'@',
address.lower() )) for address in emails }
return len(addresses)
print("Example:")
print(unique_emails(["alex@checkio.org", "mike@google.com", "lili@apple.com"]))
assert unique_emails(["alex@checkio.org", "mike@google.com", "lili@apple.com"]) == 3
assert (
unique_emails(
["mi.ke@google.com", "alex@checkio.org", "mike@google.com", "lili@apple.com"]
)
== 3
)
assert (
unique_emails(
[
"alex+home@checkio.org",
"lili+work@apple.com",
"alex@checkio.org",
"lili@apple.com",
]
)
== 2
)
assert (
unique_emails(
[
"l.ili+work@apple.com",
"a.lex@checkio.org",
"alex+home@checkio.org",
"lili+work@apple.com",
"alex@checkio.org",
"lili@apple.com",
]
)
== 2
)
assert unique_emails(["Alex@checkIO.org", "alex@checkio.org", "alex@check.io.org"]) == 2
assert unique_emails([]) == 0
print("The first mission is done! Click 'Check' to earn cool rewards!")
Nov. 17, 2021
Comments: