Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Goal
- – Oh no! The killer must have followed her on vacation! But to find them we'd have to search through 200MB of emails looking for something formatted like an address!
- – It's hopeless!
- – Everybody stand back.
- You are given a raw email archive. You must count the number of likely email addresses in there.
- As opposed to real life, a likely email address in this problem:
- • is wrapped in angle brackets <>
- • contains a unique at sign @
- • left of the at sign, contains any non-empty combination of ASCII letters, digits, and symbols ! " # $ % & ' ( ) * + , - . / : ; = ? [ \ ] ^ _ ` { | } ~
- • right of the at sign, contains any non-zero number of words separated by a dot .
- – those words must start with a letter, and may contain ASCII letters, digits, and a hyphen -
- – the last word must be letters only
- – if there's only one word, it must be succeded by a dot .
- Input
- A raw archive.
- It's so raw you do not know in advance how long it is. Read all you can until end of stream.
- (except for the site limit of 10k)
- Output
- An integer N, number of likely email addresses in the archive.
- Constraints
- The domain name need not be actually registered.
- Example
- Input
- Valid:
- - <steve@example.com>
- - <john.doe@codingame.com>
- - <un{ba[lan)cea'ble@xxx.>
- Invalid:
- - [(balanced)@example.com]
- - <inigo montoya@buttercup.net>
- - <bill@example>
- - <timey!uucp!gw!ucb>
- Output
- 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement