-2
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)
2I had thought this post is a spam when I read its title in questions list. – tsh – 2018-11-14T05:05:14.080
2Why
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.
– tsh – 2018-11-14T05:12:01.650@tsh u rite but 5 – Michael – 2018-11-14T05:13:46.013
2@Michael Why? Where are the another 2? Should dot followed by one space considered as stop of a sentence? – tsh – 2018-11-14T05:15:21.797
@tsh the code backticks remove trailing whitespace, its in my editor but not visible, just added commas – Michael – 2018-11-14T05:17:29.327
@JoKing I got u no nested, but there can be multiple sets in a sentence – Michael – 2018-11-14T05:30:22.960
2For the first example, is it unintended that the "C" is capitalized in the input? – Kamil Drakari – 2018-11-14T06:15:38.573
1You state "The 2nd, 4th, 6th, and so on sentences are corrupted.", but your first example is only a single sentence, so why are
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? – Kevin Cruijssen – 2018-11-14T09:08:36.463@KevinCruijssen I think it's one indexed – Jo King – 2018-11-14T09:22:01.470
@JoKing That's what I assumed as well, so why is the first test cases which is a single sentence (
1
in 1-indexed) corrupted with its capitalized words replaced? – Kevin Cruijssen – 2018-11-14T09:30:42.987@KevinCruijssen You're meant to ignore corrupted sentences, so it's okay to make replacements in the first sentence – Jo King – 2018-11-14T09:48:10.050
@Michael Can an input-sentence end with a trailing dot an two spaces? – Kevin Cruijssen – 2018-11-14T12:40:05.100
@Michael Should
I
in the first example be replaced withThe State
as well? Or does the single letterI
not count as a capitalized word? – Kevin Cruijssen – 2018-11-14T12:43:36.947@KevinCruijssen No replacing words in parenthesises – Jo King – 2018-11-14T20:52:29.050
@JoKing Yeah, someone else already replied that to me, but I see (s)he now deleted their message.. – Kevin Cruijssen – 2018-11-14T21:58:01.723
@KevinCruijssen I think I fixed all the vague areas in my examples, can I has main page pls – Michael – 2018-11-16T03:28:29.563