挑战在于遵循(绘制)路径:
^n
-上n行vn
-下降n行>n
-按n个字符位置<n
-左n个字符位置
n
是一个大于零的整数(即,您不会收到像这样的命令>-2
)。- 命令之间没有分隔符,格式正确的输入如下所示:
>5v8<10^3
,不允许其他形式的输入。 - 命令的数量是无限的。
- 不应再有其他字符潜入输入中。
例子。
输入是一个空字符串,输出:
*
输入是
>3
或<3
:请注意,这与输出没有任何区别:****
与
^3
和类似v3
:* * * *
输入:
>1v2
,输出:** * *
输入:
^4>3v2<1
,输出:**** * * * ** * *
如果返回并使用相同的路径,请不要绘制任何新内容。例如
>5<5
******
...虽然您没有画任何新东西,但显然可以改变位置。因此,如果您的输入如下所示:
>4<2v3
,则输出为:***** * * *
这是一个更复杂的示例:1)路径可以穿过自身2)注意,最后一条命令的最后三个步骤将整个路径向右移动。输入:
v6>4^3<7
,输出:* * * ******** * * * * *****
输入:
^2v2>3<3v3>4^5v5>3^5>4v2<4v3>4^3v3>3^5>4v2<4v3>7^5>4v2<4v3>9^3<2^2v2>4^2v2<2v3>8^5>2v4>2^4v5<3>6^5>5<5v2>5<5v2>5<4v1>8^3<1^2v2>1v2>2^3v3>2^2>1^2v2<1v3<3>11^3<2^2v2>4^2v2<2v3>5^5>5<5v2>5<5v2>5<4v1>7^5>4v2<4v3>4^3v3>3^5>4v2<3v1<1v2>3^1>1v1
输出:
* * ***** ***** ***** * * *** * ****** * * * * ****** ***** ***** * * * * * * * * * * * * * * * * * * * * * * * * ***** ***** ***** ***** ***** * * * ****** ** * ** ***** ****** ***** ***** * * * * * * * * * * * * * * * * * * ** * * * * * * * * *** ****** ***** * ****** * * * ** *******************************************************************************************
您能否提供参考实现?
—
LegionMammal978
那不是骗子吗?请决定:D
—
nicael
@nicael:我会说不是;I / O是不同的,似乎路径不能在另一个路径中交叉。我认为这在允许不同高尔夫策略的方式上更简单。但是,我不知道自己突然能够自己重新打开所有这些内容,我以为我只是在投票。
—
marinus
^2v2>3<3v3>4^5v5>3^5>4v2<4v3>4^3v3>3^5>4v2<4v3>7^5>4v2<4v3>9^3<2^2v2>4^2v2<2v3>8^5>2v4>2^4v5<3>6^5>5<5v2>5<5v2>5<4v1>8^3<1^2v2>1v2>2^3v3>2^2>1^2v2<1v3<3>11^3<2^2v2>4^2v2<2v3>5^5>5<5v2>5<5v2>5<4v1>7^5>4v2<4v3>4^3v3>3^5>4v2<3v1<1v2>3^1>1v1
。