Paramount Pictures1 photographer Adolphe L. Schafer2 set up this shot in 1934 to simultaneously flout 10 provisions of the Hays Code3 — Hollywood’s guideline for self-censorship between 1934 and 1968.
When Schafer entered the photo in an industry competition and organizers threatened him with a fine, he pointed out that the judges were hoarding all 18 prints he'd submitted.
The words of a sentence are the longest possible sequences of consecutive letters (uppercase and lowercase). We assume that no digits appear in a sentence.
We censor a word by replacing it with its first letter, followed by the length of the word (in digits). For example, the word narcotics is censored as n9 and RELATIONSHIPS as R13.
We cannot reconstruct the original word from its censored version. All we know is its first letter and length. We will therefore reveal a censored word as its first letter, followed by question marks for any letters we don't know. For example, the censored word n9 is revealed as n???????? and R13 as R????????????.
Your task:
Write a function censored that takes a word (str). The function must return the censored word (str).
Write a function revealed that takes a censored word (str). The function must return the revelation (str) of the censored word.
Write a function censor that takes a sentence (str). The function must return the sentence (str) in which all words have been censored. Characters that are no letters may not be altered when censoring the words of the sentence.
Write a function reveal that takes a censored sentence (str): a sentence in which all words have been censored. The function must return the sentence (str) in which all censored words have been revealed. Characters that are no letters may not be altered when revealing the censored words of the sentence.
>>> censored('narcotics')
'n9'
>>> censored('RELATIONSHIPS')
'R13'
>>> revealed('n9')
'n????????'
>>> revealed('R13')
'R????????????'
>>> censor('Miscegenation (interracial relationships) were not allowed.')
'M13 (i11 r13) w4 n3 a7.'
>>> censor('Words like "God," "Lord," "Jesus," "Christ," "hell," and "damn" could not be used!')
'W5 l4 "G3," "L4," "J5," "C6," "h4," a3 "d4" c5 n3 b2 u4!'
>>> reveal('M13 (i11 r13) w4 n3 a7.')
'M???????????? (i?????????? r????????????) w??? n?? a??????.'
>>> reveal('W5 l4 "G3," "L4," "J5," "C6," "h4," a3 "d4" c5 n3 b2 u4!')
'W???? l??? "G??," "L???," "J????," "C?????," "h???," a?? "d???" c???? n?? b? u???!'
Artist Bruce Timm4 made a similar image combining nine themes barred from Batman: The Animated Series5: guns, drugs, breaking glass, alcohol, smoking, nudity, child endangerment, religion, and strangulation: