Return to JUNTO

JUNTO Practice: Hackerrank, "Detect the Email Addresses"

Discussed on April 16, 2019.

Hackerrank, "Detect the Email Addresses"

Solutions

Click to see:

Oscar Martinez

import re
import sys

email_re = re.compile(r"(\b\S+@\S+\.\S+\b)")

emails = list(
    set(
        email_re.findall(
            sys.stdin.read().replace("\n", " ")
        )
    )
)
emails.sort()


sys.stdout.write(";".join(emails))

John Lekberg

import re
import sys

email_re = re.compile(r"\S+@\S+\.\w+")

candidates = set(email_re.findall(sys.stdin.read()))

print(';'.join(sorted(candidates)))