Skip to content

Instantly share code, notes, and snippets.

@martian17
Created July 8, 2022 06:27
Show Gist options
  • Save martian17/b69c1daf72ad6350cd184acf62c141b3 to your computer and use it in GitHub Desktop.
Save martian17/b69c1daf72ad6350cd184acf62c141b3 to your computer and use it in GitHub Desktop.
number decoding to ascii brainfuck
# input format
# 0 n 0 0 0 etc
# ^
# simulating input 124
>++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
>>>+<<<
# 0 124 0 0 1
# ^
# first loop: 100th place
[
>++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++
# 0 124 100 0 1
# ^
[<[->-<<]>>]
# 0 25 0 0 1 can be equal
# ^
#or
# 0 0 75 0 1
# ^
>[-
#the termination case
<<------------------------------
------------------------------
----------------------------------------
# 0 0 ―25 0 0 n
# ^
>>>[-<<<<<+>>>>>]<<
# n 0 ―25 0 0 0
# ^
]
>[
#the continuation case
>+< <<<<
]
>
]
>>>[->[-<<<<<+>>>>>]>>>]
<<<<<<
# adding 48 offset
<<++++++++++++++++++++++++++++++++++++++++
++++++++>>
# second loop: 10th place
# the code is the same as 100th place; but the input is inverted; so some signs had to be inverted
>>>+<<<
# 0 ―24 0 0 1
# ^
[
>----------
# 0 ―24 ―10 0 1
# ^
[<[+>+<<]>>]
# 0 ―4 0 0 1 can be equal
# ^
#or
# 0 0 ―6 0 1
# ^
>[-
#the termination case
<<++++++++++
# 0 0 4 0 0 n
# ^
>>>[-<<<<<+>>>>>]<<
# n 0 ―25 0 0 0
# ^
]
>[
#the continuation case
>+< <<<<
]
>
]
>>>[->[-<<<<<+>>>>>]>>>]
<<<<<<[-<+>]
#adding 48
<++++++++++++++++++++++++++++++++++++++++
++++++++
<++++++++++++++++++++++++++++++++++++++++
++++++++
<
# output
# 49 50 52 0 0 0 0 0 0
# ^
.>.>.<<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment