THINK FIRST·CODE LATER

← All labs

Redact personal data before it reaches the AI provider

Problem

Before a student's question is sent to the external AI provider, StudyBuddy must remove identifiers.

Read questions, one per line, until the end of input. Replace, in this order:

  1. Chinese resident ID numbers — 17 digits followed by a digit or X (18 characters, not part of a longer digit run) → [ID_CARD]
  2. email addresses — name@domain.tld where name and domain use letters, digits, ., _, - → [EMAIL]
  3. Chinese mobile numbers — 1 followed by a digit 3–9 and 9 more digits (11 digits, not part of a longer digit run) → [PHONE]
  4. WKU student IDs — exactly 7 digits (not part of a longer digit run) → [STUDENT_ID]

Output for each line: Q<k>: <redacted text>; if anything was replaced, add (redacted: n) with the number of replacements. A line containing an [ID_CARD] is sensitive: print Q<k>: BLOCKED - remove your ID card number and ask again instead (nothing is sent). At the end: Sent: s, Blocked: b, Redactions: r (r counts redactions in sent lines only).

Input:

Why does my loop never end?
My ID is 1234567 and my email is yuki@wku.edu.cn, why can't I log in?
Call me at 13812345678 about lab 3
My ID card is 33030219990101123X please check my account

Output:

Q1: Why does my loop never end?
Q2: My ID is [STUDENT_ID] and my email is [EMAIL], why can't I log in? (redacted: 2)
Q3: Call me at [PHONE] about lab 3 (redacted: 1)
Q4: BLOCKED - remove your ID card number and ask again
Sent: 3, Blocked: 1, Redactions: 3

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.