Some chat rooms and bulletin boards use a profanity filter to strip their
user-supplied content of words that degrade the quality of discourse. This
inspires a few foul-mouthed users to mask their objectionable language
by replacing letters with symbols of similar shape ("shoot"
may turn into "sh00t", for example), spacing out the letters ("darn" to
"d a r n"), or both ("hell" to "h e 1 1", where lowercase L is replaced
by the numeral 1).
You have been hired to make an intelligent filter that defeats these
masking techniques. For the present purposes, the only forbidden words
are "heck", "gosh", "dang", "shucks", "fooey", "snafu", and "fubar". You
are given a pair of Strings, plain and code,
such that the nth character of code may substitute for the
nth character of plain. Take into account these potential
substitutions and all possible spacings of a profane word, but disregard
the characters surrounding a profane word. Given a String
of text, return it in a censored form where all profanities are
replaced by a sequence of asterisks in such a way that the length of
the String is unaltered.
|