Better Censor

View as PDF

Submit solution

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

Author:
Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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. 14, 2015, 10:45 p.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.


  • 0
    minecraftyugi  commented on Oct. 23, 2015, 8:29 p.m.

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


    • 2
      cheesecake  commented on Oct. 23, 2015, 8:49 p.m.

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


  • 0
    Walt28  commented on Feb. 18, 2015, 8:10 p.m.

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


    • 0
      Walt28  commented on Feb. 19, 2015, 10:09 p.m.

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


    • 0
      kobortor  commented on Feb. 18, 2015, 9:12 p.m.

      Punctuation