脑干,201字节
,[[[-<+>>>+<<]>-[---<+>]<[[-<]>>]<[-]>>[<<,>>>[-[-<++++++++++>]]++++<[->+<]-[----->-<]<]<]>>>[[>>]+[-<<]>>[[>>]+[<<]>>-]]+[>>]<[-]<[<<]>[->[>>]<+<[<<]>]>[>.>]+[>[-]<,.[->+>+<<]>>----------]<[<<]>-<<<,]
在线尝试!
在输入的末尾需要尾随换行符。没有此要求的版本长6个字节:
笨蛋,207字节
,[[[-<+>>>+<<]>-[---<+>]<[[-<]>>]<[-]>>[<<,>>>[-[-<++++++++++>]]++++<[->+<]-[----->-<]<]<]>>>[[>>]+[-<<]>>[[>>]+[<<]>>-]]+[>>]<[-]<[<<]>[->[>>]<+<[<<]>]>[>.>]+[>[-]<,[->+>+<<]>>[----------<.<]>>]<[<<]>-<<<,]
在线尝试!
两种版本均假定所有数字均严格小于255。
说明
磁带的布局如下:
tempinputcopy 85 0 inputcopy number 1 a 1 a 1 r 1 d 0 w 0 o 0 l 0 f 0 ...
如果未输入数字,则“数字”单元等于0;如果输入数字n,则“ n + 1”单元等于n + 1。在标有“ 85”的单元格上输入。
,[ take input and start main loop
[ start number input loop
[-<+>>>+<<] copy input to tempinputcopy and inputcopy
>-[---<+>] put the number 85 in the cell where input was taken
<[[-<]>>] test whether input is less than 85; ending position depends on result of comparison
(note that digits are 48 through 57 while letters are 97 through 122)
<[-]> clean up by zeroing out the cell that didn't already become zero
>[ if input was a digit:
<<,>> get next input character
>[-[-<++++++++++>]] multiply current value by 10 and add to current input
++++ set number cell to 4 (as part of subtracting 47)
<[->+<] add input plus 10*number back to number cell
-[----->-<] subtract 51
<] move to cell we would be at if input were a letter
<] move to input cell; this is occupied iff input was a digit
part 2: update/output word
>>> move to number cell
[ if occupied (number was input):
[>>]+[-<<]>> remove existing marker 1s and decrement number cell to true value
[[>>]+[<<]>>-] create the correct amount of marker 1s
]
+[>>]<[-] zero out cell containing next letter from previous word
<[<<]> return to inputcopy
[->[>>]<+<[<<]>] move input copy to next letter cell
>[>.>] output word so far
+[ do until newline is read:
>[-]< zero out letter cell
,. input and output next letter or newline
[->+>+<<] copy to letter cell and following cell
>>---------- subtract 10 to compare to newline
]
<[<<]>- zero out number cell (which was 1 to make copy loop shorter)
<<<, return to input cell and take input
] repeat until end of input
0
前导数字之外没有数字0
?