John Lekberg


JUNTO Practice - "Hackerrank, "Detect the Email Addresses""

Discussed on 2019-04-16.

Hackerrank, "Detect the Email Addresses"


Solution - John

import re
import sys

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

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

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

Solution - Oscar

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))