场景
给定一个ASCII小写字母和空格的输入,绘制一个螺旋形的字符,以跟踪不包括空格的原始字符输入。
规则
1)字符应以向外的方式逆时针向左旋转。如果不能左转,则笔直移动。
Given: abcdefg
Output:
g
baf
cde
2)只要不违反规则#1,字符就可以变成先前的字符。同样,如果该字符成螺旋形,则该字符将大写。字符大写后,无论重复使用多少次,字符都将保持大写。
Given: apples appeal
Output:
PAs
PLe
ea
1
那么,如果单词继续旋转但违反了下一个字符,程序将停止吗?
—
马特
我认为让这成为一个很好的挑战的原因是您必须“倒退堆栈”,以便在使规则#1始终有效的时候讲话并继续。
—
蒂姆·雷迪
当前的措辞使规则2看起来完全是可选的。如果必须这样做,那么我认为有必要提供更全面的测试套件。
—
彼得·泰勒
输出应该是什么输入
—
彼得·泰勒
abcdefghab
?