给定一个列表或定界字符串,输出一个列表或定界字符串,其中每个单词的第一个字符一个单词。
对于此挑战,“单词”仅包含所有可打印的ASCII字符,空格,换行符和制表符除外。
例如,使用字符串“世界下午好!”。(以空格分隔):
1. String
"Good afternoon, World!"
2. Get the first characters:
"[G]ood [a]fternoon, [W]orld!"
3. Move the characters over. The character at the end gets moved to the beginning.
"[W]ood [G]fternoon, [a]orld!"
4. Final string
"Wood Gfternoon, aorld!"
这是代码高尔夫球,所以最短的代码获胜!
测试用例:
Input -> output (space-delimited)
"Good afternoon, World!" -> "Wood Gfternoon, aorld!"
"This is a long sentence." -> "shis Ts i aong lentence."
"Programming Puzzles and Code Golf" -> Grogramming Puzzles Pnd aode Colf"
"Input -> output" -> "onput I> -utput"
"The quick brown fox jumped over the lazy dog." -> "dhe Tuick qrown box fumped jver ohe tazy log."
"good green grass grows." -> "good green grass grows."