编程介的小学生 2020-02-12 21:10 采纳率: 20.5%
浏览 75

Refrigerator Magnets 冰箱磁铁问题

Problem Description
Like many families with small children, my family’s refrigerator is adorned with a set of alphabet magnets: 26 separate magnets, each containing one letter of the alphabet. These magnets can be rearranged to create words and phrases. I feel it is my parental duty to use these magnets to create messages that are witty and insightful, yet at the same time caring and supportive. Unfortunately, I am somewhat hindered in this task by the fact that I can only make phrases that use each letter once.
For example, a nice inspiring message to leave for the children might be, “I LOVE YOU.” Unfortunately, I cannot make this message using my magnets because it requires two letter "O"s. I can, however, make the message, “I LOVE MUSTARD.” Admittedly this message isn't as meaningful, but it does manage to not use any letters more than once.
You are to write a program that will look at a list of possible phrases and report which phrases can be written using refrigerator magnets.

Input
The input will consist of one or more lines, ending with a line that contains only the word “END”.
Each line will be 60 characters or less, and will consist of one or more words separated by a single space each, with words using only uppercase letters (A–Z). There will not be any leading or trailing whitespace, and there will not be any blank lines.

Output
Output only the lines which can be written in refrigerator magnets—that is, the lines which have no duplicate letters. Output them exactly the same as they were in the input—white spaces and all. Do not output the final “END” string.

Sample Input
I LOVE YOU
I LOVE MUSTARD
HAPPY BIRTHDAY
GLAD U BORN
SMILE
IMAGINE
WHATS UP DOC
HAVE A NICE DAY
END

Sample Output
I LOVE MUSTARD
GLAD U BORN
SMILE
WHATS UP DOC

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 扩散模型sd.webui使用时报错“Nonetype”
    • ¥15 stm32流水灯+呼吸灯+外部中断按键
    • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
    • ¥15 NX MCD仿真与博途通讯不了啥情况
    • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
    • ¥15 gradio的web端页面格式不对的问题
    • ¥15 求大家看看Nonce如何配置
    • ¥15 Matlab怎么求解含参的二重积分?
    • ¥15 苹果手机突然连不上wifi了?
    • ¥15 cgictest.cgi文件无法访问