All problems
PII Redaction Count
Problem
Count tokens that need PII redaction. A token is an email when it has exactly one '@', a non-empty local part, and a domain containing a dot; a token is a phone number when all of its characters are digits or '+', '-', '(', ')', '.' and it contains at least 7 digits.
Return the number of matching tokens.
Hint
Check the email rule first; only test the phone rule on tokens that did not match it.
Test cases
case 1
in: [["me@example.com","123-456-7890","hello","+1 (555) 123-4567","a@b"]]
expected: 2
case 2
in: [[]]
expected: 0
case 3
in: [["plain"]]
expected: 0
case 4
in: [["x@y.z","5551234567"]]
expected: 2
case 5
in: [["@","@."]]
expected: 0
Starter codePython
def pii_redaction_count(tokens):
# Your code here
pass5 test cases · run your code against them in the editor