Background
Joe is working on his new Brainfuck answer on Codegolf. The algorithm he's using to solve the challenge is a bit complicated, so Joe came up with idea of simplifying his Brainfuck notation to make programming easier and faster.
The challenge
Let's look at snippet written by Joe a moment ago:
0+++++1+++++0[3+0-]+1[3-2+1-]2[1+2-]3[0-3[-]]
This program was meant to check for equality of #0 and #1 cells in memory. Your task is to create a preprocessor for Joe, that will replace single digits from input with '>' and '<' characters, so the memory pointer will slide to cell specified.
Input
You may take input from any source - function parameter, standard input, or any other device. The input might be in form of a stream, string, or a byte array.
The input may contain characters from all over the ASCII range, but can't contain brainfuck memory pointer instructions (<
& >
).
All the digits you see in the input are expected to be placed here just for your program.
Output
As Joe didn't write his preprocessor yet, he had to make the code interpretable by hand. That's the result he got:
+++++>+++++<[>>>+<<<-]+>[>>-<+<-]>[<+>-]>[<<<->>>[-]]
There are pretty much no restrictions on output - if the input has braces unbalanced, just copy them over in unbalanced amount to the output.
Bonus tasks
If you think the challenge is too boring in current form, you might want to complete these tasks aswell for slight byte count reduction, and more fun obviously:
Optimize out nonsense related to memory operations, like digits at the end of input or clustered digits (just take the last one) - 20% of byte amount when completed
Minify Brainfuck output (remove clustered
+-
,><
, non-brainfuck, comments and other kind of stuff) - 20% of byte amount when completed
Rules
- Standard loopholes are forbidden by default
- Default I/O rules apply
- Programs are scored by their size in bytes.
- Solving additional tasks reduces the score.
- If anything is unclear, please let me know down in the comments
- Scoring of bonus tasks may increase (but not decrease!) in the future.
Opening bid - C, 144 bytes
p,c,x;void g(v){x=v?'<':'>';if(v<0)v*=-1;while(v--)putchar(x);}main(){while((c=getchar())!=-1)if(isdigit(c)){c-=48;g(c-p);p=c;}else putchar(c);}
This program should make pretty much everything clear on the input and output side of this challenge, it doesn't implement any bonus tasks though.