FreeChat Online
It is 1985, and you are a humble Russian potato farmer. Sadly, your glorious homeland is going through a time of crisis and it needs your help! The KGB, with the "assistance" of your wife and children, has convinced you to build their up-and-coming government FreeChat Online service for high ranking soviet officials. Luckily, the Russian government has provided you with several items seized through routine surveillance of the US's technological innovations—a cutting edge Macintosh XL, and the prototype source code for LucasArts's Habitat, an advanced communication service with cutting edge graphics. Your task is simple: create a few modifications for the Russian government…
Due to Communism's tendency to coalesce toward collectivistic cultures, the Russian government wants this chat to embody their perfect world—one without silly notions of self or individualism. Alas, Macintosh compatibility leads you astray. Due to problems in the prototype, every other sentence in the chat buffer is corrupted, except for the ending period. Lucky for you, the Russian people make classification easy for you.
CHALLENGE:
For a String s
in the input, there are 1 or more sentences, separated by ". "
(period, TWO spaces) The 2nd, 4th, 6th, and so on sentences are corrupted. The last sentence may have nothing, "."
, ". "
, or ". "
as its end. Here's some examples of an input:
"L'etat c'est moi (I am the state) - King Louis XIV"
|----------------one sentence, ended by nothing--------------|
"Hello World. GojdGojog. How are you. "
|--three sentences, one corrupted, ended by ". "
--|
"Hi. gfhyG. My favorite food is Baseball. jijhojh. Foobar. "
|---------------Five sentences, two corrupted, ended by ". "
-----------|
You must process this string, replacing any capitalized word besides the first word of a sentence, words in parentheses (no nested, but there can be multiple sets in a sentence), or corrupted sentences with the string "The State"
.
Examples:
"L'etat c'est moi (I am the state) - King Louis XIV"
--->"L'etat c'est moi (I am the state) - The State The State The State"
"Hello World. GojdGojog. How are you. "
--->"Hello The State. GojdGojog. How are you. "
"Hi. gfhyG. My favorite food is Baseball. jijhojh. Foobar. "
--->"Hi. gfhyG. My favorite food is The State. jijhojh. Foobar. "
Rules:
Standard Loopholes are prohibited
ASCII Text Input
If the input doesn't match the specifications set above, do whatever you please with the output!
This is code-golf, so the shortest(valid)answer (in each language) wins!
Bonus points for a one-liner 😎 (Not really tho, just cool points)
Hi. gfhyG. My favorite food is Baseball. jijhojh. Foobar.
is 4 sentences? Should it be 3?Hi.
,gfhyG.
,My favorite food is Baseball. jijhojh. Foobar.
\$\endgroup\$King Louis XIV
replaced with 3xThe State
? Also, as mentioned by @KamilDrakari above, why isn't theC
(orC'est
) not replaced withThe State
while theKing Louis XIV
are? \$\endgroup\$