Better Censor

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types

The Society for the Prevention of Profanity on the Internet has realized that many people were able to circumvent their censorship system by using special characters. For example, four is a four letter word that needs to be censored, however, people will put it at the end of a sentence, as in four., and the censorship system breaks apart. Another case where it breaks apart is when people try to use 1337 speak, such as l33t or 1337.

Your task is to write a program that censors all four letter words with ****, even if they are surrounded by punctuation or written in 1337 speak.

Input Specification

The input to your program consists of an integer, n, on a line by itself, followed by n lines of text. Each line of text contains ASCII text containing letters, symbols, and spaces. Lines do not exceed 80 characters in length.

Output Specification

Output each line of text, with four letter words replaced by ****, while preserving all other characters, including spaces.

Sample Input

6
The Society for the Prevention of Profanity on the Internet has realized that
many people were able to circumvent their censorship system by using special
characters. For example, "four" is a four letter word that needs to be
censored, however, people will put it at the end of a sentence, as in "four.",
and the censorship system breaks apart. Another case where it breaks apart
is when people try to use 1337 speak, such as "l33t" or "1337".

Sample Output

The Society for the Prevention of Profanity on the Internet has realized ****
**** people **** **** to circumvent their censorship system by using special
characters. For example, "****" is a **** letter **** **** needs to be
censored, however, people **** put it at the end of a sentence, as in "****.",
and the censorship system breaks apart. Another **** where it breaks apart
is **** people try to use **** speak, **** as "****" or "****".

Comments


  • -1
    Anix55  commented on Nov. 15, 2015, 3:45 a.m.

    does anyone know how to use the POSIX character classes in python? For some reason, none of the character classes work. Is there an alternative to such since python doesn't support it.


  • -2
    minecraftyugi  commented on Oct. 24, 2015, 12:29 a.m.

    Are numbers considered as words? For example, would 1234 be censored or not?


    • 2
      cheesecake  commented on Oct. 24, 2015, 12:49 a.m.

      In the sample case, 1337 (near the end) is censored. So yes, numbers are included.


  • -2
    Walt28  commented on Feb. 19, 2015, 1:10 a.m.

    Is there any thing other than letters and numbers that I need to take into account?


    • -2
      Walt28  commented on Feb. 20, 2015, 3:09 a.m.

      I mean, for the words we must censor, is it only letters and numbers that we must replace with "*"?


    • -3
      kobortor  commented on Feb. 19, 2015, 2:12 a.m.

      Punctuation