Quantcast
Channel: Write a Stack Exchange compliant brainfuck explainer - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 17

Answer by Fmbalbuena for Write a Stack Exchange compliant brainfuck explainer

$
0
0

Vyxal 3, 80 79 bytes

Dð4×§,0$"<>+-.,[]"£([¥nc[⁰Lm-ꜝð×§¹,|n§1#x)4m+ð×§¥nḞꜝ:[#?Ḣin§⁰Lm-ð×§,0|n§1][ð§¹,

Try it Online!

Explanation:

Setup:

Dð4×§,0$"<>+-.,[]"£(­⁡​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁣​‎⁠⁠⁠⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏⁠‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏‏​⁡⁠⁡‌⁤​‎⁠⁠⁠⁠‎⁡⁠⁢⁡⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‏​⁡⁠⁡‌⁢⁢​‎⁠⁠⁠⁠⁠‏​⁡⁠⁡‌­ð4×§                 ## ‎⁡Print "    " without newlineD    ,                ## ‎⁢Print the first line of input with newline"<>+-.,[]"£   ## ‎⁣Put "<>+-.,[]" in the register      0$              ## ‎⁢⁡Push the 0 in the stack (Swapped because the top of the stack is used for looping)                   (  ## ‎⁤Loop every char in the first line of input

Looping part:

[¥nc[⁰Lm-ꜝð×§¹,|n§1#x)4m+ð×§¥nḞꜝ:[#?Ḣin§⁰Lm-ð×§,0|n§1]­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏⁠‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏⁠‎⁡⁠⁢⁢⁢‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢⁣‏⁠‎⁡⁠⁢⁢⁤‏⁠‎⁡⁠⁢⁣⁡‏⁠‎⁡⁠⁢⁣⁢‏⁠‎⁡⁠⁢⁣⁣‏⁠‎⁡⁠⁢⁣⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁤⁡‏⁠‎⁡⁠⁢⁤⁢‏⁠‎⁡⁠⁢⁤⁣‏⁠‎⁡⁠⁢⁤⁤‏⁠‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁣⁡⁡‏⁠‎⁡⁠⁣⁡⁢‏⁠⁠‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁣⁡⁣‏⁠‎⁡⁠⁣⁡⁤‏⁠‎⁡⁠⁣⁢⁡‏⁠‎⁡⁠⁣⁢⁢‏⁠‎⁡⁠⁣⁢⁣‏⁠‎⁡⁠⁣⁢⁤‏⁠‎⁡⁠⁣⁣⁡‏⁠‎⁡⁠⁣⁣⁢‏⁠‎⁡⁠⁣⁣⁣‏⁠‎⁡⁠⁣⁣⁤‏⁠‎⁡⁠⁣⁤⁡‏⁠‎⁡⁠⁣⁤⁢‏⁠‎⁡⁠⁣⁤⁣‏⁠‎⁡⁠⁣⁤⁤‏⁠‎⁡⁠⁤⁡⁡‏‏​⁡⁠⁡‌⁢⁤​‎‎⁡⁠⁤⁡⁢‏⁠‎⁡⁠⁤⁡⁣‏⁠‎⁡⁠⁤⁡⁤‏⁠‎⁡⁠⁤⁢⁡‏⁠‎⁡⁠⁤⁢⁢‏‏​⁡⁠⁡‌­[¥nc[                                                   ## ‎⁡if the current character is in "<>+-.,[]"⁰Lm-ꜝð×§¹,                                         ## ‎⁢print that many spaces, then the second line of input, with newline.               |n§1#x)                                  ## ‎⁣else print the current character and continue with the 1 in the top of the stack.                      4m+ð×§                            ## ‎⁤Print that many spaces¥nḞꜝ                        ## ‎⁢⁡index of the current character (1 to 8, 0 if not found)                                :[                      ## ‎⁢⁢if the index of the current character is 1 or more                                  #?Ḣin§⁰Lm-ð×§,0       ## ‎⁢⁣Print that many spaces, then the right explanation, with newline, and push 0                                                 |n§1]  ## ‎⁢⁤else, print the current character, and push 1

Final part:

[ð§¹,­⁡​‎‎⁡⁠⁡‏⁠⁠⁠⁠‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠⁠‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌­[      ## ‎⁡If the top of stack is 1 or greater       ## ‎⁢(I have no idea why that works)ð§    ## ‎⁣print " " without newline¹,  ## ‎⁤Print the second line of input, with newline💎

Created with the help of Luminespire.


Viewing all articles
Browse latest Browse all 17

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>