Run Length Encoded Brainfuck, 49 bytes
Since there are no variables in Brainfuck, I just used standard input and output instead.
The code 32+
should be interpreted as 32 +
s by the interpreter. Just replace them manually if your interpreter doesn't support RLE.
>,[32->+<[16-<[>++<-]>[<+>-]>-<]>[<<.[-]>>-]<,]<.
Expanded (non-RLE) version: (91 bytes)
>,[-------------------------------->+<[----------------<[>++<-]>[<+>-]>-<]>[<<.[-]>>-]<,]<.
The code assumes that EOF is encoded as 0.
Explanation
The following layout is used:
+---+---+------+
| x | a | flag |
+---+---+------+
Where x
is the ASCII byte to be printed, a
is the a character from standard input and flag
is 1 if a
was a space.
>, Read a character a into the second cell
[ While not EOF:
32- Decrease a by 32 (a -= ' ')
>+< Set the flag to 1
[ If a was not a space:
16- Decrease by 16 more ('0' == 32+16)
<[>++<-] a += 2*x
>[<+>-] Move it back (x = a)
>-< Reset the flag, it was not a space.
]>
[ If a was a space (flag == 1):
<<.[-] Print and reset x
>>- Reset the flag
]
<, Read the next caracter a
]
<. Print the last character x
ZX81
here. \$\endgroup\$