Model A
```python
def dedupe_emails(emails: list[str]) -> list[str]:
"""
Removes duplicate email addresses case-insensitively, trims whitespace,
skips empty strings, and keeps the first occurrence order.
Args:
emails (list[str]): A list of email addresses.
Returns:
list[str]: A list of unique email addresses.
"""
# Create a set to store unique email addresses
unique_emails = set()
# Create a list to store the result
result = []
# Iterate over each email in the input list
for email in emails:
# Trim whitespace and convert to lowercase
trimmed_email = email.strip().lower()
# Check if the email is not empty and not already in the set
if trimmed_email and trimmed_email not in unique_emails:
# Add the email to the set and the result list
unique_emails.add(trimmed_email)
result.append(email)
return result
# Example asserts
assert dedupe_emails(["test@example.com", "test@example.com", "test2@example.com"]) == ["test@example.com", "test2@example.com"]
assert dedupe_emails(["test@example.com", "test@example.com", "test@example.com"]) == ["test@example.com"]
assert dedupe_emails(["", "test@example.com", "test@example.com"]) == ["test@example.com"]
```
This function works by iterating over each email in the input list, trimming whitespace, converting to lowercase, and checking if it's not empty and not already in the set. If it meets these conditions, it's added to the set and the result list. The function returns the result list, which contains the unique email addresses in the order they first appeared in the input list.Generated tokens: 366
The check stays hidden until you reveal this card.