空格,141个 104 103字节
[S S S N
_Push_0][S N
S _Duplicate_0][T N
T T _Read_STDIN_as_number][T T T _Retrieve][S S S T S N
_Push_2][T S S T _Subtract][S N
S _Duplicate_input-2][N
T T N
_If_negative_Jump_to_Label_-1][S S S T N
_Push_1][S N
S _Duplicate_1][T N
S T _Print_as_integer][S S T T N
_Push_-1][T N
S T _Print_as_integer][T S S T _Subtract][N
S S T N
_Create_Label_LOOP][S N
S _Duplicate][N
T T S N
_If_negative_Jump_to_EXIT][S S S T N
_Push_1][S N
S _Duplicate_1][T N
S T _Print_as_integer][T S S T _Subtract][N
S N
T N
_Jump_to_LOOP][N
S S N
_Create_Label_-1][T N
S T _Print_as_integer][N
S S S N
_Create_Label_EXIT]
字母S
(空格),T
(制表符)和N
(换行符)仅作为突出显示而添加。
[..._some_action]
仅作为说明添加。
1
代替C
和-
代替打印E
。
-1字节感谢@JoKing通过建议使用1
and -1
代替0
and 1
。
伪代码中的解释:
Integer i = STDIN-input as integer - 2
If i is negative (-1):
Print i (so print "-1")
Else:
Print "1-1"
Start LOOP:
If i is negative:
EXIT program
Print "1"
i = i-1
Go to the next iteration of the LOOP
示例运行:
输入: 1
Command Explanation Stack Heap STDIN STDOUT STDERR
SSSN Push 0 [0]
SNS Duplicate top (0) [0,0]
TNTT Read STDIN as integer [0] {0:1} 1
TTT Retrieve heap at 0 [1] {0:1}
SSSTSN Push 2 [1,2] {0:1}
TSST Subtract top two [-1] {0:1}
SNS Duplicate input-2 [-1,-1] {0:1}
NTSN If neg.: Jump to Label_-1 [-1] {0:1}
NSSN Create Label_-1 [-1] {0:1}
TNST Print top as integer [] {0:1} -1
NSSSN Create Label_EXIT [] {0:1}
error
在线尝试(仅使用空格,制表符和换行符)。
因错误而停止:未定义退出。
输入: 4
Command Explanation Stack Heap STDIN STDOUT STDERR
SSSN Push 0 [0]
SNS Duplicate top (0) [0,0]
TNTT Read STDIN as integer [0] {0:4} 4
TTT Retrieve heap at 0 [4] {0:4}
SSSTSN Push 2 [4,2] {0:4}
TSST Subtract top two [2] {0:4}
SNS Duplicate input-2 [2,2] {0:4}
NTSN If neg.: Jump to Label_-1 [2] {0:4}
SSSTN Push 1 [2,1] {0:4}
SNS Duplicate top (1) [2,1,1] {0:4}
TNST Print as integer [2,1] {0:4} 1
SSTTN Push -1 [2,1,-1] {0:4}
TNST Print as integer [2,1] {0:4} -1
TSST Subtract top two [1] {0:4}
NSSTN Create Label_LOOP [1] {0:4}
SNS Duplicate top (1) [1,1] {0:4}
NTTSN If neg.: Jump to Label_EXIT [1] {0:4}
SSSTN Push 1 [1,1] {0:4}
SNS Duplicate top (1) [1,1,1] {0:4}
TNST Print as integer [1,1] {0:4} 1
TSST Subtract top two [0] {0:4}
NSNTN Jump to Label_LOOP [0] {0:4}
SNS Duplicate top (0) [0,0] {0:4}
NTTSN If neg.: Jump to Label_EXIT [0] {0:4}
SSSTN Push 1 [0,1] {0:4}
SNS Duplicate top (1) [0,1,1] {0:4}
TNST Print as integer [0,1] {0:4} 1
TSST Subtract top two [-1] {0:4}
NSNTN Jump to Label_LOOP [-1] {0:4}
SNS Duplicate top (-1) [-1,-1] {0:4}
NTTSN If neg.: Jump to Label_EXIT [-1] {0:4}
NSSSN Create Label_EXIT [-1] {0:4}
error
在线尝试(仅使用空格,制表符和换行符)。
因错误而停止:未定义退出。