编程介的小学生 2017-01-13 06:41 采纳率: 20.5%
浏览 861
已采纳

A Tale from the Dark Side of the Moon

Description

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

Them: We cannot. We lost the source code.

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

Them: The manual page does mention something about the 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! What do you know about the program?

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

Us: What kind of modification?

Them: It removes any character that is not a lowercase letter. But not white spaces. White spaces are preserved as seen in the input.

Us: Do you have a sample input/output?

Them: Plenty. Here’s one. (see next section.)

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

Them: It works on any text as long as the lines are less then eighty characters wide. It doesn’t seem to mind working on lengthy documents. But it does terminate once it sees the sequence "EOF" (without the double quotes.)

One of them: Don’t forget to tell them about the "dd" thingy.

Us: What "dd" thingy?

Them: Whenever it sees a pair of small letter "d", one right after the other, it replaces them with "p".

Us: Why?

Them: Who knows? It just does that!

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

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

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

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

Us: What about "vv"?

Them: Every "vv" is replaced with a "m".

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

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

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

Them: No. That was the program.

Us: What else?

Them: One last thing. It seems to be replacing every "ei" with "ie".

Us: Every one of them?

Them: Except if it comes right after "c" then it remains as is.

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

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 2008 if we get it right.

Us: Yeah! Right.

Sample Input

unpinked is an 8 letter word. Honest!
vv is ok, d123d is ok, 123dd is not
i received mail from liechtenstein
.. ...adding means to imitat.#$!%%$e
EOF
Sample Output

unfloyded is an letter word onest
vv is ok dd is ok p is not
i received mail from liechtenstien
aping means to imitate

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-01-18 15:56
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题