挑战
好吧,我认为这很清楚,不是吗?您必须创建一个函数或程序,该函数或程序将字符串作为参数并输出对应的Yoda语言。
这是code-golf,因此最少的字节数获胜。
输入
输入可以是没有换行符的任何字符串。如果字符串是这样组成的,则可以翻译它:
主语 +动词+其他。
其中Subject是人称代词(我,您,他,她,它,我们,他们)。您不必认识到第二个单词是动词。
如果第一个单词不是代词,则输入有效,但输出为 Too difficult, this sentence is.
You have to win this code challenge -> Translatable
Luke has to win this code challenge -> Untranslatable
输入可以以字母a结束。或!,而不是?。
此外,字符串可以包含Non-Ascii,括号,逗号,冒号...
输出
对于可翻译的句子,输出是相同的句子,主语和动词位于句子的末尾。
You have to win this code challenge -> To win this code challenge, you have.
代词中的逗号,句号和小写字母是必填项。(当然,如果代词是I)。
如前所述,如果不可翻译,则必须输出字符串 Too difficult, this sentence is.
例子
You have to win this code challenge -> To win this code challenge, you have.
He won this code challenge -> This code challenge, he won. (I know this is not yoda-speaking, but I don’t want to overcomplicate this challenge)
I ate an ice cream earlier! -> An ice cream earlier, I ate.
I liked the Star Wars original trilogy more than the prequel’s one. -> The Star Wars original trilogy more than the prequel’s one, I liked.
I find your lack of faith disturbing -> Your lack of faith disturbing, I find.
I think we are done with the examples -> We are done with examples, I think.
He is your son, Vader -> Your son, Vader, he is.
I think they’ll add new features -> They’ll add new features, I think.
I made a fantastic code challenge (I hope) -> A fantastic code challenge (I hope), I made.
I love constants like π -> Constants like π, I love.
I’ll be the next President, I swear! -> Too difficult, this sentence is.
This challenge is great! -> Too difficult, this sentence is.
Is this challenge great? -> Too difficult, this sentence is.
Luke is not ready for this task -> Too difficult, this sentence is.
Somebody loves constants like π -> Too difficult, this sentence is.
[Empty string] -> Too difficult, this sentence is.
!
怎么办?是否保证不会发生这种情况,还是我们应该处理这种情况并打印出与没有主导代词时相同的内容。输入中可以包含换行符吗?使徒?冒号/括号/反引号?非ASCII字符?您说“输入可以是任何字符串”,但是您的测试用例仅涵盖非常特定类型的字符串。
You have to win this code challenge
应该为This code challenge, you have to win
。