A Tale from the Dark Side of the Moon#1628

A Tale from the Dark Side of the Moon

1 second
64 megabytes
Easy

Us: So why don't you just recompile the program on the new hardware?

Them: We can't. We've lost the source code.

Us: How typical! What does the program do? Do you have any documentation?

Them: The manual page mentions something about documentation in the source code.

Us: A manual page is good. What does it say?

Them: Just one line: See the source code for more information.

Us: Argh! So, what do you know about the program?

Them: Well, it seems to take simple text, similar to that found in an English dictionary, and prints it after some modification.

Us: What kind of modification?

Them: It removes any character that is not a lowercase letter, but it does preserve whitespaces. Whitespaces are left unchanged as in the input.

Us: Do you have a sample input/output?

Them: Plenty. Here's one. (See the next section.)

Us: This is rather small! Did you try it on anything bigger?

EOF

Them: It works on any text, as long as the lines are less than eighty characters wide. It doesn't seem to mind working on lengthy documents. However, it terminates when it sees the sequence dd (without the double quotes).

One of them: Don't forget to tell them about the thingy.

dd

Us: What thingy?

d

p

Them: Whenever it sees a pair of consecutive lowercase letters dp, it replaces them with dd.

Us: Why?

Them: Who knows? It just does that!

ddd

dddd

Us: What about ddd and dddd? How does it behave then?

dddd

ddd

Them: Where in English will you find a ddd or even a dddd? Haven't you been listening?

Us: Oops. We'll pay more attention. Anything else?

vv

Another one of them: There is also the thingy vv.

vv

Us: What about vv?

vv

m

Them: Every vv is replaced with an m.

Yet another one of them: No, wait! That was a printer problem. It had nothing to do with the program. Remember?

vv

Them: Oh, that's right. Forget about the thingy vv.

dd

Us: What about the thingy? Was that just a printer problem too?

Them: No. That was the program.

Us: What else?

ei

ie

Them: One last thing. It seems to replace every ei with ie.

Us: Every one of them?

c

Them: Except if it comes right after ie, then it remains as is.

Us: Makes sense. That's all, right?

pink

floyd

Them: No, we just remembered one more thing: It replaces the sequence pink with floyd anywhere in the text.

Us: What?! Who wrote this program? Why do you need it in the first place?

Them: We think it will increase our chances of going to Banff in April if we get it right.

Us: Yeah! Right.

Examples

Example 1

Loading
Loading