出于当前挑战的目的,“概述”一个单词的意思是先用最后一个字母依次包围它自己的字母,最后用空格替换中心的原始单词:
oooooo
onnnno
on -> on no
onnnno
oooooo
任务:
给定一个仅由小写和/或大写英文字母组成的单词列表,勾勒出每个单词的轮廓,并水平相邻显示所有生成的块,并用一列单空格隔开,在块的中心垂直对齐。
您可以编写完整的程序或函数。
输入:
单词列表,或者如果您愿意-用空格或其他符号分隔的字符串
输出:
轮廓词块的ASCII表示形式。允许前导/尾随空格。
测试用例:
Input 1: ["code", "golf"] (or "code golf")
Output 1:
cccccccccccc gggggggggggg
cooooooooooc goooooooooog
coddddddddoc gollllllllog
codeeeeeedoc golfffffflog
code edoc golf flog
codeeeeeedoc golfffffflog
coddddddddoc gollllllllog
cooooooooooc goooooooooog
cccccccccccc gggggggggggg
Input 2: ["I", "am", "just", "a", "man"] (or "I am just a man")
Output 2:
jjjjjjjjjjjj
juuuuuuuuuuj mmmmmmmmm
aaaaaa jussssssssuj maaaaaaam
III ammmma justtttttsuj aaa mannnnnam
I I am ma just tsuj a a man nam
III ammmma justtttttsuj aaa mannnnnam
aaaaaa jussssssssuj maaaaaaam
juuuuuuuuuuj mmmmmmmmm
jjjjjjjjjjjj
获奖标准:
每种语言中以字节为单位的最短代码获胜。如果您评论/解释您的代码和方法,我将不胜感激。
我们可以假设至少有一个词吗?
—
PurkkaKoodari '18
@ Pietu1998是的,总是至少有一个字
—
Galen Ivanov
@Kevin Cruijssen转置?
—
Galen Ivanov