text:
Asterisks viral
Given a positive integer N ("virality"), your program should create an ASCII-art drawing of a tree with two branches of length N extending downwards and/or rightwards from the top-left corner.
The direction taken by each branch after the first asterisk can be either rightwards or downwards, and this choice should be made randomly1 at every next step.
For example, given an input of 5, the output might look like:
***
* ***
**
 **

The two branches are allowed to touch (be on adjacent cells), but not overlap (be on the same cell), so the following would not be allowed:
***
* *
*****
  *
  *

Examples
For input 1, the only possible output is:
**
*

(This will be present in all valid outputs, since having the two branches take the same path would cause them to overlap.)
Possible outputs for an input of 3 include:
***
* *
**

**
***
*
*

For input 7:
****
*  **
*   **
*
***
  *

For input 10:
****
*  *
*********
  *
  *****

This is code-golf, so the shortest valid answer (in bytes) wins.
1. This should uniformly random (i.e. a 50/50 chance of each direction),
 or as close to uniformly random as you can get on normal hardware.

Please comment if you're having any problems with consuming my long post - maybe I can shorten something (I'll try then).

Just learn to expect that. Sometimes it's busy as all heck. Other times it's quiet like it is now. Don't forget, it's also Easter.

I am not really sure what is wrong with my post. Would the one who downvoted be so kind to explain, please?

@EsolangingFruit ok, this makes me think that something in the wording is also unclear, right? As for the name: by looking at the front page, you can see that it looks like he name of my previous question, i.e. rhymes, which was actually intended :)

@esolang oh and i've edited it too, feel free to dismiss/roll back my edit (i am not editing further not to confuse you again), sorry!

Thank you very much for spending your time to improve my post, @EsolangingFruit! Are you sure that the illustration is irrelevant and the test case can be interpeted with ease without the image?

@nicael I didn't find it a problem. It might be helpful to add a similar image after the very first example.

@EsolangingFruit why did you edit out "Trailing spaces/newlines/whatever invisible are allowed." and "You don't have to handle inputs less than 1."? The former is rather crucial to the spec and the latter was still helpful.

@O.O.Balance The former is implied by the tag [ascii-art] (this meta consensus establishes that [ascii-art] is intended to produce a certain appearance, not necessarily an exact byte stream). The latter is implied by the term "positive integer" at the start.

@EsolangingFruit thanks for the [ascii-art] link. Still figuring out all the places on this site where rules are specified.

@O.O.Balance ... Mostly hidden around [meta].

Both those versions can be considered "uniformly random" at each step, while they may produce different resulting distribution. Are they equivalent or which one do you want?

@user I think they are equivalent, I would accept any

IMO N is better described as time :P

FYI, after some discussion in chat we concluded that those 2 methods produces different distribution.

Because harder challenges receive fewer answers. Don't worry too much about that...

@user202729 thanks for infotmation! I don't really care about the distribution, if all the theoretically possible outputs are possible in the actual solution.

Consider editing the challenge to relax the restriction (which is not well-defined as pointed out)... Besides, it appears that many existing answers doesn't satisfy that anyway.

Can we return a matrix of 0s and 1s instead of spaces and asterisks?

CJam, 58 51 bytes
[TT]{_2_m*\f.+{:-},mR}ri*]ee{~\)S*\{'*t}/}%::a:.+N*

Try it online!
The basic idea is that we start with [0 0] and then repeatedly add either 0 or 1 to each element (making sure that they are never equal except at the start to avoid overlap), collecting all intermediate results.
[[0 0] [0 1] [0 2] [0 2] [1 3]]

We then create a large array of arrays where each subarray contains * at indices given by the corresponding pair in the original array and spaces everywhere else.
["*"
 "**"
 "* *"
 "* * "
 " * * "]

This yields diagonal slices of the output matrix (where moving left to right corresponds to moving top-right to bottom-left in the actual matrix).
We can then use ::a:.+ to "de-diagonalize" and get the resulting lines:
[ "**** "
  "*  *"
  "** "
  " *"
  ""     ]

Java 10, 273 272 268 239 bytes
n->{var c=new char[++n][n];for(var d:c)java.util.Arrays.fill(d,' ');for(int i=0,j=0,k=0,l=0,r=0,s=0,t=0,u=0;n-->0;){c[i+=r][j+=s]=c[k+=t][l+=u]=42;do{r=t=2;r*=Math.random();t*=Math.random();s=r^1;u=t^1;}while(i+r==k+t&j+s==l+u);}return c;}

Try it online here.
Thanks to Kevin Cruijssen for golfing 29 bytes.
Ungolfed version:
n -> { // lambda taking an int as argument
    var c = new char[++n][n]; // the output; increment the virality since the root does not count
    for(var d : c) // for every line
        java.util.Arrays.fill(d,' '); // initialize it with spaces
    for(int i = 0, j = 0, // coordinates of the first branch
            k = 0, l = 0, // coordinates of the second branch
            r = 0, s = 0, // offsets for the first branch, one will be 0 and the other 1 always except for the first '*' where the two branches overlap
            t = 0, u = 0; // offsets for the second branch, one will be 0 and the other 1 always except for the first '*' where the two branches overlap
        n-- > 0; ) { // decrement virality and repeat as many times
        c[i+=r][j+=s] = c[k+=t][l+=u] = 42; // move according to offsets and place an '*' for each branch, 42 is ASCII code
        do { // randomly pick offsets for both branches
            r = t = 2; // Math.random() provides results in [0,1)
            r *= Math.random(); // flip a coin for the first branch
            t *= Math.random(); // flip another coin for the second
            s = r^1; // set s to 0 if r=1, to 1 if r=0
            u = t^1; // set u to 0 if t=1, to 1 if t=0
        } while(i+r==k+t&j+s==l+u); // repeat if the branches overlap
    }
    return c; // return the output
}

239 bytes (I've only changed the things inside the do{} a bit (and placed the ints in the first part of the for-loop). PS: In your initial answer the 0.5 could have been golfed to .5 as well.

@KevinCruijssen looks like I need to work on my math. thanks :-)

237 bytes

Charcoal, 31 24 bytes
Ｆ²«Ｊ⁰¦⁰Ｆ⊕θ«¿ι*↓*≔‽²ι¿ＫＫ↗

Try it online! Link is to verbose version of code. Originally I thought it would be easier to make the first step random but it turned out to be golfier to make the first branch predictable. Explanation:
Ｆ²«

Loop twice, using index variable i. (This actually iterates over an implicit list, so it's safe to mutate i inside the loop.)
Ｊ⁰¦⁰

Jump to the origin of the canvas.
Ｆ⊕θ«

Loop N+1 times.
¿ι*↓*

Print a *, but leave the cursor either to the right or below the cursor depending on the value of i.
‽²ι

Randomise the value of i for the next iteration of the inner loop.
¿ＫＫ↗

If the current character is a *, this means that we're the second branch and we went down instead of right, so move up right to correct that.
 (The first branch always starts downwards so the second branch will always be above it, meaning that we only need to check for a vertical collision.)

It's almost correct, however it prints not N-sized branches, but N-1 sized :)

@nicael Sorry, fixed.

You've probably already seen this too many times, but: 23 bytes

Perl 5, 208 124 122 118 bytes
118 bytes without newlines, indentation and comments. Takes N from stdin:
@b=1..2;                            #number of branches is 2
for(1..<>){                         #add length <> (the input) to each branch
  ($x,$y)=@$_                       #get where current branch has its tip now
 ,.5>rand?$x++:$y++                 #increase either x or y
 ,$o[$y][$x]++&&redo                #try again if that place is already occupied
 ,$_=[$x,$y]                        #register new tip of current branch
   for@b                            #...and do all that for each branch
}
say map$_||!$i++?'*':$",@$_ for@o;  #output the branches

Try it online!

Nice, but it prints the branches 1 asterisk shorter than they should be :)

Please see the examples in my questions again :)

Oh, I've changed 2..$N to 1..shift now and also shaved off a few bytes.

Now everything seems to be ok!

Good answer! You can save a few bytes using <> and input instead of shift and arguments as well as re-orderinf you call to rand to avoid the parens. You shouldn't need to wrap your assignment to @o either. I tried using @b=([],[]); which appears to work, but I didn't experiment too much so I might've missed an edge case there. Hope they help a little!

Thx @DomHastings I got rid of 2 bytes with your rand tip. Also your tip on <> worked for me locally, but I couldn't figure out how to get it working in TIO so I kept shift for now. I found out for myself before: using @b=1..2 and getting rid of @o=....

Yeah, I spotted you'd updated it once I'd added my comments! If using <> on TIO you need to use input field instead of arts. I've also replaced ' ' with $" for another cheeky byte off! Try it online!

I figured out TIO: needed to click remove on the arg even though it was empty. So now both your <> and $" tips are added. Still got something to learn in Perl5, and Perl6 is an even bigger bag of tricks I haven't dared to thread too far into yet.

The tips for golfing in Perl page has some good advice, be sure to check it out! Good luck and have fun!

A couple more tips: you can safely omit the final ;, and using map instead of your first for would save another byte.Try it online!

Python 2, 204 bytes
from random import*
N=input()
s=eval(`[[' ']*-~N]*-~N`)
s[0][0]='*'
I=x,y=1,0
J=X,Y=0,1
exec"s[y][x]=s[Y][X]='*';i,j,k,l=choice((J+I,I+I,I+J,J+J)[x-2<X:]);x+=i;y+=j;X+=k;Y+=l;"*N
for i in s:print`i`[2::5]

Try it online!

Perl 5 -a, 97 96 93 92 bytes
Has no right, down or off diagonal bias.
#!/usr/bin/perl -a
@;=[1];map{$x=$y=0;map++(.5<rand?$x:$y)*$;[$y][$x]++&&redo,1.."@F"}1,2;say+($","*")[@$_]for@

Try it online!

PHP, 118 bytes
for($r="*",$w=$argn+2;$argn--;$r[$q+=rand(0,$r[$q+1]<"*")?:$w]=$r)$r[$p+=rand(!$i++,1)?:$w]=$r;echo wordwrap($r,$w-1);

requires PHP 5.4 or later for the Elvis operator. Replace ?: with ?1: for older PHP.
Run as pipe with -nR or try it online.

How do I check with different input there?

@nicael: You can change the argument on the line $argBak=$argn=

Ok! Not sure whether this is a nice way or not to "accept" input this way, but let the community decide by voting

@nicael In the TiO, simply replace the value for $argn. In a real environment, $argn comes from STDIN if you run it as a pipe with -R. It will then execute the code for each line of input (but I am pretty certain PHP does not unset the variables inbetween; so explicit consecutive runs are more likely to avoid bad surprises.)

Red, 195 190 bytes
func[n][g: func[s][i: 0 d: s while[i < n][b/(d): #"*"until[r: 1 if 1 = random 2[r: n + 1]b/(d + r) =#" "]d: d + r
i: i + 1]]b:""loop n[loop n[append b" "]append b"^/"]b/1: #"*"g n + 2 g 2 b]

Try it online!
Readable:
f: func[n][
    g: func[s][
        i: 0
        d: s
        while[i < n][
            b/(d): #"*"
            until[
                r: 1 if 1 = random 2[r: n + 1]
                b/(d + r) = #" "
            ]
            d: d + r
            i: i + 1
        ]
    ]
    b: ""
    loop n[loop n[append b " "]append b "^/"]
    b/1: #"*"
    g n + 2
    g 2
    b
]

Jelly, 50 43 41 bytes
2ḶẊ⁸Ð¡+\‘Ṗ
⁸ÇU;Ç¤⁻Q$¿
‘,þ`⁼€þÇS+»þ`Ị$ị⁾*

Try it online!
This was a really fun one to write. There could be some much more optimal method. There is probably some golfing to do within this method as well.
Right after I posted this I realized I could use ,þ` instead of aþ,""oþ`Ɗ.

R, 148 142 bytes
n=scan();`~`=sample;o=r=k=1;l=c(1,n);for(i in 1:n){r=r+l~1;t=l~1;k=k+"if"(k+t-r,t,l[l!=t]);o=c(o,r,k)};write(c(" ","*")[1:n^2%in%o+1],1,n,,"")

Try it online!
Additionally, although it won't meet the output spec, you can distinguish the two branches: Try it online!
Explanation:
Starting from index 1, we randomly select a right or left move for branch r by adding n or 1, respectively. Then we select another right or left move for branch k, and if it would intersect where r is going, we select the other direction. Then we use r and k as indices into m, setting those values as "*". Iterating n-1 times, we then print the result.

Jelly, 39 38 bytes
ḣ2+\€Ẏ
2Rd¤ṗẊÇ⁻Q$$¿Ç0,0ṭ‘Ṭ€×þ/$€Sị⁾* Y

Try it online!
Although seemingly unrelated, d is useful here to save a byte (over my previous approach).

Python 2, 191 187 176 bytes
from random import*
n=input()
p,q=c=1,1j;s={p,q,0}
exec'z=choice(c);q,p=p+[z,1+1j-z][p+z in s],q;s|={q};'*2*~-n
R=range(n+1)
for y in R:print''.join(' *'[y+x*1jin s]for x in R)

Try it online!
Python has native support for complex numbers of the form a+bj; this makes some 2-D problems a bit more tractable...


text:
Expand compressed brain-flak
This challenge was posted as part of the April 2018 LotM challenge, as well as for Brain-flak's 2nd birthday

I was thinking about what the most efficient way to encode brain-flak programs would be. The obvious thing to do, since there are only 8 valid characters, is to map each character to a 3-bit sequence. This is certainly very effective, but it's still very redundant. There are some features of brain-flak code that we could take advantage of to shorten the encoding.

The nilads, which are all represented by 2 matched brackets, really act as a single unit of information rather than 2. If we replaced each bracket with a single byte character, this would make the encodings much smaller without losing any data.
This one is less obvious, but the closing bytes of the monads are redundant too. Think you could guess what the '?' characters represent in the following snippet?
 {(({}?<>?<>?

If we assume the input is valid brain-flak code, then there is only one option for each of those question marks. This means that we can unambiguously use a close monad character to represent every closing bracket. This has the added benefit of keeping the character set small, which would greatly help if we wanted to use a huffman encoding. Since the close monad character will most likely be the most common character by a wide margin, it could be represent by a single bit, which is hugely efficient.

These two tricks will let us compress brain-flak code via the following algorithm:

Replace every closing bracket of a monad with |. Or in other words, replace every closing bracket that is not preceded by it's opening match with a bar. So...
(({})<(()()())>{})

would become
(({}|<(()()()||{}|

Replace every nilad with it's closing bracket. Therefore, matched brackets with nothing in them use the following mapping:
() --> )
{} --> }
[] --> ]
<> --> >

Now our last example becomes:
((}|<()))||}|

Remove trailing | characters. Because we know that the total number of bars should equal the total number of ({[< characters, if there are bars at the end missing, we can infer them. So an example like:
({({})({}[()])})

would become
({(}|(}[)

Your challenge for today is to reverse this process.
Given a string of compressed brain-flak containing only the characters (){}[]<>|, expand it into the original brain-flak code. You can assume that the input will always expand to valid brain-flak. This means that no prefix of the input will ever contain more | than ({[< characters.
The input will not contain trailing | characters. These must be inferred from context.
As usual, you can submit either a full program or a function, and input/output formats are permissive. And since this is a code-golf, your code will be scored by the length of the source code in bytes, the smaller the score the better.
Test cases
Here are some test cases. If you would like more, you can generate your own test cases with this python script and the Brain-Flak Wiki, which is where the majority of these test cases come from.
#Compressed code
#Original code

())))
(()()()())

([([}()||||(>||{(})|>|}{((<}|||>}|}>}
([([{}(())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}

({(}|(}[)|||}
({({})({}[()])}{})

(((()))||(](((}}||(}([(((}))||||(]((}}|}|}}|||]||]|[))||(}))|}(}|(}]]|}
((((()()()))([]((({}{}))({}([((({}()())))]([](({}{}){}){}{})))[]))[])[()()])({}()()){}({})({}[][]){}

genius. absolutely genius.  You should make a derivative language.

@NH. Personally, I feel like languages that only differ in encoding are really boring.

@dj but this one would take up less bytes and therefore be better for golfing.

Brain-Flak wasn't designed to be good at golfing.

Brain-Flak, 952 916 818 bytes
{(({})[(((()()()()()){}){}){}])((){[()](<{}>)}{}){{}(({})()<>)(<>)}{}(<>)<>(({})[(((()()()){}){}()){({}[()])}{}])((){[()](<{}>)}{})({}<>{})<>(({})[((((()()()()()){}){})){}{}])((){[()](<{}>)}{})({}<>{})<>(({})[(((((()()()()()){}){}){}())){}{}])((){[()](<{}>)}{})({}<>{}){{}(<(<>({})()()<>)>)}{}<>(({})[(((()()()()()){}){}){}()])((){[()](<{}>)}{}){{}(({})[()])(<>)<>(<({}<{({}<>)<>}{}>)>)<>{({}<>)<>}{}(<>)}{}(<>)<>(({})[(((((()()()()()){})){}{}())){}{}])((){[()](<{}>)}{})({}<>{})<>(({})[((((()()()()()){}){})()){}{}])((){[()](<{}>)}{})({}<>{})<>(({})[(((((()()()()()){}){}){}())()){}{}])((){[()](<{}>)}{})({}<>{}){{}<>(<(({})[()()])(<>)<>(<({}<{({}<>)<>}{}>)>)<>{({}<>)<>}{}>)}{}<>(({})[(((((()()()()()){}){})()){}{}){}])((){[()](<{}>)}{}){{}{}(<(<>{}<>)>)}{}(<>)<>(<({}<{({}<>)<>}{}>)>)<>{({}<>)<>}{}<>}{}{({}<>)<>}<>

Saved 360 bytes by calculating opposing brackets relatively rather than from scratch (e.g. ')' = '(' + 1 instead of (((5 * 2) * 2) * 2) + 1)
Saved 34 bytes with some direct replacements from DJMcMayhem
Saved 10 bytes by overlapping the >]} handling code
Saved 118 bytes by deduplicating rolls
Saved 40 bytes by taking advantage of the empty stack to simplify the first roll
Saved 48 bytes by marking EOF with -1, enabling more concise roll code
Saved 36 bytes by using the stock equals logic instead of my own
Saved 98 bytes thanks to Jo King finding a more efficient way to build the output
Try it online!
First time golfing in Brain-Flak, so there are probably some really big improvements, but it works. Lots of copy/paste to handle each bracket type, and big thanks to the automatic integer generator and the Roll snippet from here.
Explanation here, TIO formats it more easily
Bonus answer:
Compressed Brain-Flak 583 bytes
{((}|[((()))))|}|}|}||(){[)|(<}|||}|{}((}|)>|(>||}(>|>((}|[((()))|}|})|{(}[)|||}||(){[)|(<}|||}|(}>}|>((}|[(((()))))|}|}||}}||(){[)|(<}|||}|(}>}|>((}|[((((()))))|}|}|})||}}||(){[)|(<}|||}|(}>}|{}(<(>(}|))>||||}>((}|[((()))))|}|}|})||(){[)|(<}|||}|{}((}|[)||(>|>(<(}<{(}>|>|}||||>{(}>|>|}(>||}(>|>((}|[((((()))))|}||}})||}}||(){[)|(<}|||}|(}>}|>((}|[(((()))))|}|}|)|}}||(){[)|(<}|||}|(}>}|>((}|[((((()))))|}|}|})|)|}}||(){[)|(<}|||}|(}>}|{}>(<((}|[))||(>|>(<(}<{(}>|>|}||||>{(}>|>|}|||}>((}|[((((()))))|}|}|)|}}|}||(){[)|(<}|||}|{}}(<(>}>||||}(>|>(<(}<{(}>|>|}||||>{(}>|>|}>|}{(}>|>|>

Try it online!
(Note that the above link does not run because TIO doesn't have a Compressed Brain-Flak interpreter. You can find a transpiler to Brain-Flak here)
I have checked that this is valid by transpiling to Brain-Flak using this tool, now efficient enough that timing out is unlikely.

First time golfing in Brain-Flak, and the result is this? Wow.

You can always replace <>(<()>) with (<>). Also, you can change (<>{}<>)(<()>) to (<(<>{}<>)>)

There seems to be a lot of rolling. Surely you can combine some of those?

@JoKing I wouldn't know how, I barely managed to extract the Roll at the end of the loop instead of having an extra one in every If block

Do you still have multiple rolls in it? I have some ideas for how you could get rid of some of them, but I can't work on it since it seems like the explanation is out of date.

@DJMcMayhem As of the last update I still have the rolls, but I'm working on another change now that should cut a lot of them

This is beyond golfing .. This is pure madness. Congratulations !

I'll upvote this as soon as I remove my jaw from the floor, bear with me

Instead of -1 as the EOF, you could just separate the input and the output by a zero and append the new values to the top of the output stack. Then at the end you can reverse it onto the other stack, saving you the large chunk at the end, as well as the trouble of pushing something to the bottom of the stack at the beginning (since Brain-Flak has implicit 0s at the bottom of the stack)

@JoKing I'm not sure I understand your suggestion. Right now there are 3 things I store: Input, Output, and a sequence of closing brackets. Right now, the Input and Output are both on the left stack separated by -1, while the closing brackets are on the right. Is the suggestion that the brackets should be stored on the same stack as input while output is built up on the right stack?

No, everything stays the same, except input and output are separated by a 0 instead of -1 and you append to the top of the output instead of the bottom. This cuts out everything before the main loop and 80% of everything after

@JoKing The change was both easier and more effective than I expected, and now included in the answer

Retina 0.8.2, 103 98 bytes
[])}>]
$&;
T`])}>|`[({<;
r`(.*)((;)|(?<-3>.))*
$&$.1$*;
(?<=(.)((;)|(?<-3>.))*);
;$1
T`;-{`_>-}`;.

Try it online! Link includes test cases. Edit: Saved 5 bytes with inspiration from @MartinEnder. Explanation:
[])}>]
$&;
T`])}>|`[({<;

Put a ; after every close bracket and change them all to open brackets, and change the |s to ;s too.
r`(.*)((;)|(?<-3>.))*
$&$.1$*;

Count the number of unmatched open brackets and add that many ;s.
(?<=(.)((;)|(?<-3>.))*);
;$1

Copy each opening bracket to its matching ;.
T`;-{`_>-}`;.

Flip the copied brackets and delete the ;s.

You could avoid all the escaped bars if you translate | to something like !. It wouldn't even cost bytes if you translate >-} to <-{ (which I think gives z for |).

@MartinEnder Not sure I understand your point about the z but I came up with way of shaving a few more bytes off anyway.

TIS, 670 666 bytes
-4 bytes for jumping forward to jump back
Code:
@0
MOV UP RIGHT
@1
MOV ANY ACC
SUB 41
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
MOV ACC DOWN
@2
NOP
MOV 124 LEFT
@3
MOV ANY DOWN
@4
MOV UP ACC
JGZ O
MOV 40 LEFT
JLZ (
MOV 41 LEFT
JRO 3
O:SUB 21
MOV ACC DOWN
JRO -8
(:MOV 41 RIGHT
@5
MOV ANY DOWN
@6
MOV ANY DOWN
@7
MOV UP ACC
JGZ O
MOV 60 LEFT
JLZ <
MOV 62 LEFT
JRO 3
O:SUB 31
MOV ACC DOWN
JRO -8
<:MOV 62 RIGHT
@8
MOV ANY DOWN
@9
MOV ANY DOWN
@10
S:MOV UP ACC
JGZ O
MOV 91 LEFT
JLZ [
MOV 93 LEFT
JRO 3
O:SUB 31
MOV ACC DOWN
JRO -8
[:MOV 93 RIGHT
@11
MOV ANY DOWN
@12
MOV ANY DOWN
@13
MOV UP ACC
JEZ |
MOV 123 LEFT
JLZ {
MOV 125 LEFT
JRO 2
|:MOV DOWN LEFT
JRO -7
{:MOV 125 RIGHT
@14
MOV ANY DOWN
@15
MOV UP DOWN
@16
MOV UP LEFT

Layout:
6 3
CCCCCCCCCCCCCCCCSC
I0 ASCII -
O0 ASCII -

Try it online!
I doubt this is smallest, but I don't see a way to make it smaller. Unfortunately, all the NOPs seem necessary for timing, and I can't put the stack where @14 currently is because of the read from ANY in @11.
The structure of this solution is as follows:
Input
  |
  V
  0    1:synchro  2:EOF
  3    4:parens     5
  6    7:angles     8
  9   10:squares   11
 12   13:curlies   14
 15      stack     16
  |
  V
Output

Upon seeing an open brace, the open is sent along the left column to be output, and the close is sent along the right column to the stack.
Upon seeing a close brace, the open and close are both sent along the left column to be output.
Upon seeing a pipe, the stack is popped and sent to output.
Upon EOF, @1 will begin reading from @2, instead of the input stream from @0. @2 produces an endless stream of pipes, so the stack will be drained.
Once both the input and the stack are exhausted, the program halts.
Warning: due to the limitations of TIS, the stack size is limited to 15. If anything is nested deeper than that, this implementation will produce an incorrect result.

JavaScript (ES6), 107 bytes
Takes input as an array of characters. Returns a string.
a=>a.map(c=>(n=(S='|()[]{}<>').indexOf(c))?n&1?(s=[S[n+1],...s],c):S[n-1]+c:s.shift(),s=[]).join``+s.join``

Try it online!

102 bytes by returning a character array, too.

@Shaggy Thanks! But is it really allowed to return 1-character and 2-character strings mixed together?

Hmm ... yeah, maybe that's pushing it on "permissive" output.

@DJMcMayhem Would you please have a look at the new output format and let us know if that's acceptable?

@arnauld Huh, for some reason that didn't ping me. I think I'd say no. An array of characters or one string are both standard formats, but an array of strings doesn't seem valid to me

@DJMcMayhem That makes sense. I rolled back to the previous version. Thanks for your feedback!

Ah, well, it was worth a try!

@DJMcMayhem If I'm not mistaken, pings on answers only work if you're the author or you've commented on the answer yourself.

Brain-Flak, 606 548 496 418 394 390 bytes
{((({})))(<>)(((((((([(())()()()]){}){}){}())(()))(((())()())()){}{})){}[()])({<(({}<>{}[()]))>(){[()](<{}>)}{}<>}{}<><{}>){({}({})<>)(<>)}{}({}<>)(<>)(((((((([(())()()()]){}){}){}())(()))(((())()){}()){})){})({<(({}<>{}[()]))>[()]{()(<{}>)}{}<>}{}<>){(<({}(<()>)<>({})<{({}<>)<>}>)>)<>{({}<>)<>}}{}({}()<>){{}({}<>)((<>))}{}{}<>(<({}(<()>)<><{({}<>)<>}>)>)<>{({}<>)<>}{}<>}{}{({}{}<>)<>}<>

Try it online!
I started this by golfing Kamil Drakari's answer, but it got away from me to the point where I decided to post it as a separate answer.
Explanation:
{ #While input on stack
	((({})))(<>)	#Preserve copy of the character
	(((((		#Push the differences between start bracket characters
	((([(())()()()]){}){}){}())	#Push -31, 1
	(()))				#Push -30, 1
	(((())()())()){}{})		#Push -19, 1
	){}[()])			#Push -39
	({<(({}<>{}[()]))>(){[()](<{}>)}{}<>}{}<><{}>)	#If the character is any of the start brackets
	{({}({})<>)(<>)}{}					#Push the current character + TOS to the other stack

	({}<>)(<>)
	(((((		#Push the differences between end bracket characters
	((([(())()()()]){}){}){}())	#Push -31, 1
	(()))				#Push -30, 1
	(((())()){}()){})		#Push -19, 1
	){})				#Push -40
	({<(({}<>{}[()]))>[()]{()(<{}>)}{}<>}{}<>)	#If the character is any of the end brackets
	{(<({}(<()>)<>({})<{({}<>)<>}>)>)<>{({}<>)<>}}{}	#Push the character + TOS to the output

	({}()<>)	#If the character is not a |
	{{}({}<>)((<>))}{}	#Move current character to the other stack and push a zero
	{}		#Pop the top value of the stack, either the | or a 0
	<>(<({}(<()>)<><{({}<>)<>}>)>)<>{({}<>)<>}{}<>	#And push top of other stack to the output
}{}
{({}{}<>)<>}<>	#Reverse output and append the excess end brackets

And of course...
Compressed Brain-Flak, 285 bytes:
{(((}|||(>|(((((((([()|)))||}|}|})|()||((()|))|)|}}||}[)||({<((}>}[)||||){[)|(<}|||}>|}><}||{(}(}|>|(>||}(}>|(>|(((((((([()|)))||}|}|})|()||((()|)|})|}||}|({<((}>}[)||||[)|{)(<}|||}>|}>|{(<(}(<)||>(}|<{(}>|>|||||>{(}>|>||}(})>|{}(}>|((>|||}}>(<(}(<)||><{(}>|>|||||>{(}>|>|}>|}{(}}>|>|>

Very impressive golfing! I'm disappointed in myself for not noticing this sooner, I'll have to delve into it later to understand how it works.

Ruby, 104 bytes
a=[];$<.chars{|c|r="|[{(<>)}]";i=r.index(c);i<1||(i<5?a:$>)<<r[-i];$>.<<i<1?a.pop: c};$><<a.reverse.join

This is a full program that outputs to the console. (i<5?a:$>)<<r[-i] has got to be one of the coolest golfs I have ever done.
Try it online!
Ruby, 106 bytes
->s{a=[];(s.chars.map{|c|r="|>)}][{(<";d=r[-i=r.index(c)];i<5||a<<d;i<1?a.pop: i<5?d+c:c}+a.reverse).join}

This is my first solution. An anonymous lambda function that takes and returns strings.
Try it online!

Haskell, 127 121 bytes
(""#)
(u:t)#('|':b)=u:t#b
s#(c:b)|elem c")>]}"=m c:c:s#b|q<-m c:s=c:q#b
s#b=b++s
m c="> < ] [)(} {"!!mod(fromEnum c-6)27

Try it online!
Edit: -6 bytes by using @Laikoni's function to find the matching bracket.

Java 10, 424 bytes
s->{int i=0;for(var c:s.toCharArray()){if("(<[{".indexOf(c)>-1)i++;if(c=='|')i--;}for(;i-->0;)s+='|';s=s.replace(")","()").replace(">","<>").replace("]","[]").replace("}","{}");char[]c=s.toCharArray(),r=new char[124];r[40]=41;r[60]=62;r[91]=93;r['{']='}';var o="";for(;++i<c.length ;){if(c[i]=='|'){c[i]=o.charAt(0);o=o.substring(1);}if("(<[{".indexOf(c[i])>-1&")>]}".indexOf(i+1<c.length?c[i+1]:0)<0)o=r[c[i]]+o;}return c;}

It's kind of lengthy, but I couldn't figure out how to shorten it further.
This is a nice challenge though.
Try it online here.
Ungolfed version:
s -> { // lambda taking a String argument and returning a char[]
    int i = 0; // used for counting the number of '|'s that have been removed at the end of the input
    for(var c : s.toCharArray()) { // look at every character
        if("(<[{".indexOf(c) > -1) // if it's an open monad character
            i++; // we will need one more '|'
        if(c == '|') // if it's a close monad character
            i--; // we will need one '|' less
    }
    for(; i-- > 0; ) // add as many '|'
        s += '|';    // as necessary
    s = s.replace(")", "()").replace(">", "<>").replace("]", "[]").replace("}", "{}"); // replace compressed nilads with their uncompressed versions
    char[] c = s.toCharArray(), // from now on working on a char[] is more efficient since we will only be comparing and replacing
    r = new char[124]; // map open monad characters to their counterparts:
    r[40] = 41;   // '(' to ')'
    r[60] = 62;   // '<' to '>'
    r[91] = 93;   // '[' to ']'
    r['{'] = '}'; // '{' to '}'
    var o = ""; // we use this String as a kind of stack to keep track of the last open monad character we saw
    for(; ++i < c.length ;) { // iterate over the length of the expanded code
        if(c[i] == '|') { // if the current character is a close monad character
            c[i] = o.charAt(0); // replace it with the top of the stack
            o = o.substring(1); // and pop the stack
        }
        if("(<[{".indexOf(c[i]) > -1 // if the current character is an open monad/nilad character
         & ")>]}".indexOf(i+1 < c.length ? c[i+1] : 0) < 0) // and it's not part of a nilad (we need to test for length here to avoid overshooting)
            o = r[c[i]]+o; // using the mapping we established, push the corresponding character onto the stack
    }
    return c; // return the uncompressed code
}

414 bytes

Python 2, 188 184 180 177 174 173 bytes
p,q='([{<',')]}>'
d,s,a=dict(zip(p,q)),[],''
for c in input():
 if c in d:a+=c;s+=[c]
 elif'|'==c:a+=d[s.pop()]
 else:a+=dict(zip(q,p))[c]+c
for c in s[::-1]:a+=d[c]
print a

Saved 4 bytes thanks to DJMcMayhem.
Try it online!

180

168 bytes by messing with the 2nd to last line

@DJMcMayhem That only works if s ends up empty.  Otherwise, you end up with the extra characters at the wrong end.

Python 3, 122 bytes
D='()<>[]{} '
def f(x):
 a=s=''
 for c in x:i=D.find(c);a+=i<0and s[0]or D[i-(i&1):i+1];s=D[i+1][i&1:]+s[i<0:]
 return a+s

Try it online!

Python 2, 244 bytes
s=input()
B='([{<'
C=')]}>'
Z=zip(B,C)
P=sum(map(s.count,B))-s.count('|')
for i,j in Z:s=s.replace(j,i+j)
s+=P*'|'
b=[0]
for i in s:[b.pop()for j,k in Z if j==b[-1]<k==i];b+=[i][:i in B];s=i=='|'and s.replace(i,C[B.find(b.pop())],1)or s
print s

Try it online!
It took way more than an hour or two to get this working...

Haskell, 152 bytes
fst.p
m c="> < ] [)(} {"!!mod(fromEnum c-6)27
p(c:r)|elem c")]}>",(s,t)<-p r=(m c:c:s,t)|c/='|',(s,'|':t)<-p$r++"|",(u,v)<-p t=(c:s++m c:u,v)
p e=("",e)

Try it online! or verify all test cases. p implements a recursive parser, which might be over kill for the simple grammar.

Nice function m to find the matching bracket.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Roguelike pathfinding
Roguelike pathfinding
Your task will be, given a two-dimensional array of the elements described below, which represents a dungeon, to output or return a single number representing the amount of gold pieces the rogue can collect without waking up any monsters.
The elements of the array are as follows:

Empty spaces are represented by either . or a space, your call;
Rogue's starting position is represented by, of course, @;
A gold piece is represented by $;
Walls are represented by #;
Monsters are represented by characters from the following regexp: [a-zA-Z*&].

The array shall not contain any characters not listed above, so you can assume that anything that is not a wall, an empty space, the rogue or a gold piece is a monster.
The rules for pathfinding are:

The rogue can only walk through empty cells or cells containing gold;
It takes a turn to move to a adjacent or diagonally adjacent cell;
Picking up the gold is instant;
The rogue can't stay adjacent or diagonally adjacent to a monster for more than one turn without waking it up, which is forbidden;
The rogue can enter the awareness area of a monster any number of times, the monster will only wake up if the rogue spends two consecutive turns near it.

Input and output rules
You can get the input in any reasonable format, including a two-dimensional array, a flat array, a string or whatever else. If it makes your life easier, you may also take the dimensions of the array as well.
It's guaranteed that the rogue will not be near a monster at the beginning.
A full program or a function is fine.
Scoring
This is code-golf, the score is the bytes count of your submission with fewer being better.
Test cases
I use dots for empty spaces here for readability purposes, if you so desire you may use spaces (see above). Also note that this is a pure coincidence that the rogue is always in the upper-left corner, your code should handle any other valid position as well.
1)
@..
.$.
...  -> 1

Just a sanity test.
2)
@....
...g$
.....  -> 0

Again, a sanity test.
3)
@....
...$g
.....  -> 1

The rogue can grab the gold by moving in from the left.
4)
@....g..
.......$
........
.....h..  -> 1

The rogue can zig-zag between the monsters, never staying for more than one turn near each.
5)
@....z..
.......$
.....b..  -> 0

The tactics from the previous test case don't work here - the monster sensitivity areas overlap.
6)
@$#.
###$
....  -> 1

Sanity test.
7)
@..#..
$.$g.$
...#..  -> 2

Ditto.
8)
@#.d#$
$...##
e.....
..$...
##..$b
.#..g$  -> 3

Of all the gold here, only three can be reached safely: the gold near the starting position can be got by moving down one and then back to the starting position. To escape from the top left corner the rogue has to move diagonally down-right twice. The gold in the middle poses no challenge. The outer gold guarded by g and b can be got by moving in diagonally from the place to the right of the middle gold and then back. The rest cannot be got: top-right gold is blocked by walls, and the bottom-right gold requires two turns in monster sensitivity areas.
The following test cases were generously donated by mbomb007.
9)
  12345678
a @....g.D
b .......$
c ......#.
d .....h..  -> 1

This one is tricky. A path is b4-b5-c6-b7-c8-b8(grab).
10)
  12345678
a @....g.D
b .......$
c .......#
d .....h..  -> 1

A path is [bc]4-c5-b6-c7-b8(grab).
11)
  12345678
a @....g.D
b ......#$
c .......#
d .....h..  -> 1

The extra wall doesn't actually change anything, [bc]4-c5-b6-c7-b8(grab) is still a solution.

You should add a larger and more complex example. Also, what are the minimum and maximum dimensions of the dungeon? Is the 1x1 dungeon @ a valid input?

Some other examples.

@mbomb007 I've added a new example. As to the size of the grid, I think limiting it to at least 3x3 is reasonable.

@mbomb007 Mind if I edit your examples in? They, once understood, showcase the logic very well.

Feel free. That's what I made them for. It could also be noted that rotating a test case should have no impact on its result.

in the test below "sanity test" why cant he pick the third gold? the rules sais that we cannot stay "close" to the monster for over a turn but a turn is all we need (we come from the bottom, take it and return to the previous cell)

@DanielIndie I've numbered the tests to avoid possible confusion. Which one do you refer to?

@Michail test case 7

Test case 3: "The rogue can grab the gold by moving in from the left and then moving outside the goblin's reach before it wakes up". I don't understand "moving outside the goblin's reach before it wakes up". Once the rogue has the gold, there's no need to move.

@DanielIndie Not sure if I understand you correctly, the path to the third (rightmost) gold is blocked off completely by walls and a monster in 7)

@PeterTaylor True, I'll remove the confusing phrase.

can i assume that if a cell is not (@,.,#,$) then its a monster?

@DanielIndie Sure, a valid input should not contain any extraneous characters, so it's a fair assumption. I'll edit that in.

previous solutions (part of them) can be found in the footer container in the tio link (those are probably more readable)
JavaScript (Node.js),883 436 411 360,345 311 bytes
g=>g.map((r,y)=>[...r].map((c,x)=>A+=c=="$"&&P(g,x,y)),A=0)|A
P=(g,x,y,m={},p={},I=i=9,M={})=>{if(/[.$]/.test(c=(g[y]||0)[x])){for(;i--;)if(/^[^.@$#]$/.test(C=(g[y+~-(i/3)]||0)[x+i%3-1])){if(m[C])return
M[C]=1}for(;I--;)if(!p[(X=x+~-(I/3))+","+(Y=y+I%3-1)]&&P(g,X,Y,M,{...p,[x+","+y]:1}))return 1}return c=="@"}

Try it online!
Explantion -
instead of going from the player to the cash i went from the case to the @. i think i should be faster because i know when to stop looking (reach the @) , and when you look for cash you need to always keep moving until you covered all of the spots (and the ways to get to them). so the algo is pretty simple that way - the main function
g.map((r,y)=>[...r].map((c,x)=>A+=c=="$"&&P(g,x,y)),A=0)|A:
find cash -> if you found it -> start looking for the player -> if you found him -> increment A
now lets got to the path finder aka P
if(/[.$]/.test(c=(g[y]||[])[x])) just check if the current cell is "special" -> if so we want to return if its a player. special cases : @#(monster)
for(;i--;)
if(/^[a-zA-Z*&]$/.test(C=(g[y+~-(i/3)]||0)[x+i%3-1])) -> if my neighbor is a monster
{if(m[C])return false -> and it already was in the previous turn - this path is not value
M[C]=1} -> if not just add it to the neighbors monsters
for(;I--;)
if(!p[(X=x+~-(I / 3))+","+(Y=y+I%3-1)]&&P(g,X,Y,M,{...p,[x+","+y]:1}))return true iterate neighbors again - if i wasn't already there (p is the path taken)
continue path (call P)

Nice golfing! A few things I noticed: (1) your code has superfluous trailing whitespace on the 2nd and 7th lines, and most line breaks are needless (only lines 1 and 6 need a break), and I / 3 has needless space. Eliminate that whitespace and your score is actually 324! (2) return true  can be return 1 (a truthy value) and return false can simply be return (implied undefined, a falsey value). (3) The regex ^[^.@$#]$ to check for no non-monsters is shorter than ^[a-zA-Z*&]$ to check for monsters. Nice work!

yes i know i can make it a lot shorter :)

@apsillers updated to the spaces free solution :)

Python3, 710 bytes
E=enumerate
def F(s,c,C,O,e,M,x,y,U):
 r=[]
 for X,Y in s:e[(x,y)]=e.get((x,y),[])+[((X,Y),c)];r+=[(O+[(x,y)],X,Y,c+C*((X,Y)not in U),M,U+[(X,Y)]*C)]
 return r
def f(b):
 d,D={4:[]},[]
 for x,r in E(b):
  for y,v in E(r):d[K]=d.get(K:=[[[[4,3][v=='$'],2][v=='#'],1][v=='.'],0]['@'==v],[])+[(x,y)];D+=[(x,y)]
 C,e=[],{}
 q=[([],*d[0][0],0,set(),[])]
 while q:
  O,x,y,c,M,U=q.pop(0)
  if c==len(d[3]):return c
  o={a:[(x+X,y+Y)for X,Y in[(0,1),(0,-1),(1,0),(-1,0),(1,1),(1,-1),(-1,1),(-1,-1)]if(P:=(x+X,y+Y))in b and[]==[1 for(J,K),w in e.get((x,y),[])if(J,K)==P and w>=c]]for a,b in d.items()}
  if not M&{*o[4]}:C+=[c];q=F(o[3],c,1,*(P:=[O,e,{*o[4]},x,y,U]))+q+F(o[1],c,0,*P)+F(o[0],c,0,*P)
 return max(C+[0])

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Integers in Base Pi
Background:
Pi (π) is a transcendental number, and therefore it has a non-terminating decimal representation. Similar, the representation doesn't terminate if written in any other integer base. But what if we wrote it in base π?
Digits in decimal represent powers of 10, so:
π = 3.14… = (3 * 10^0) + (1 * 10^-1) + (4 * 10^-2) + …

So in base π, the digits would represent powers of π:
π = 10 = (1 * π^1) + (0 * π^0)

In this new base, integers now have non-terminating representations. So 10 in decimal now becomes the following:
10 => 100.01022… = (1 * π^2) + (0 * π^1) + (0 * π^0) + (0 * π^-1) + (1 * π^-2) + …

Note that in base π the digits used are 0,1,2,3 because these are the digits less than π.
Challenge:
Given a non-negative integer x, either:

Output (without halting) its representation in base π. If the number has a finite representation (0, 1, 2, 3), then the program may halt instead of printing infinite zeros.

Take an arbitrarily large integer n, and output the first n digits of x in base π.

Rules:

Since a number has multiple possible representations, you must output the one that appears the largest (normalized). Just as 1.0 = 0.9999… in decimal, this problem exists in this base, too. In base π, one is still 1.0, but could also be written as 0.3011…, for example. Similarly, ten is 100.01022…, but could also be written as 30.121… or 23.202….
This is code-golf, so fewest bytes wins. Program or function.
No built-ins (I'm looking at you, Mathematica)

Results:
0       = 0
1       = 1
2       = 2
3       = 3
4       = 10.220122021121110301000010110010010230011111021101…
5       = 11.220122021121110301000010110010010230011111021101…
6       = 12.220122021121110301000010110010010230011111021101…
7       = 20.202112002100000030020121222100030110023011000212…
8       = 21.202112002100000030020121222100030110023011000212…
9       = 22.202112002100000030020121222100030110023011000212…
10      = 100.01022122221121122001111210201201022120211001112…
42      = 1101.0102020121020101001210220211111200202102010100…
1337    = 1102021.0222210102022212121030030010230102200221212…
9999    = 100120030.02001010222211020202010210021200221221010…

First 10,000 digits of ten in base Pi
Verification:
You can verify any output you want using the Mathematica code here. The first parameter is x, the third is n. If it times out, pick a small n and run it. Then click "Open in Code" to open a new Mathematica worksheet with the program. There's no time limit there.
Convert the resulting output to a number here.
Related:

Wikipedia: Non-integer representation
Quora: What is 10 in base pi?
Math.SE: What would a base π number system look like?
XKCD forum: Counting in a base pi number system?

Does "no built-ins" include no built-ins for getting Pi?

@Nit No, it means no built-in that completes or trivializes the entire task. Or if such a built-in exists (like the Mathematica one I showed), make sure to include a solution without the built-in which will be used for the answer's actual score. That way, you still get to show people that the built-in exists.

Can we use a limited-precision π literal?

@EriktheOutgolfer No. That will not be sufficient to arrive at correct output. Though I'm not sure how many digits are required for an input of n, I'd guess that Pi must have at least n digits of precision.

@mbomb007 Well, outputs wrong only because of floating-point limitations are allowed by default, that's why I asked.

@EriktheOutgolfer I gave a list of 10000 digits of ten in base Pi. If you can't arrive at that output, then your program is not correct.

Related

IMO: Banning base conversion builtins just adds needless complexity. If you feel like it trivializes the challenge, well, maybe the challenge is just that: trivial

Strongly rely on real storage

I feel like there was a guidance against banning built-ins and instead simply not upvoting answers that were uninteresting. Anyone have a meta-link to that?

@LyndonWhite I'm well aware. That's why I said people can post an answer using them, as long as they also post one without. That way they also have to do the work. We all know that people upvote short answers regardless of the recommendations.

Julia 0.6, 81 bytes
f(x,i=log(π,x)÷1)=(y=big(π)^i;d::Int=x÷y;print(i==0?"$d.":"$d");f(x-d*y,i-1))

Prints out digits (and the . which cost me 14 bytes) until it Stack overflows at about 22k digits on TIO. If I'm allowed to pass the input as a BigFloat I can cut 5 bytes. Makes use of the built in arbitrary precision constant π. But its a bit cooler than that, its actually an adaptive precision constant, π*1.0 is a 64 bit floating point number, π*big(1.0) (aka multiplied by an higher precision number) gives π at whatever your precision is set to.
Try it online!

Python 3, 471 317 310 bytes
7 bytes thanks to caird coinheringaahing.
Surely there are golfs that I missed. Feel free to point them out in the comments.
def h(Q):
	a=0;C=b=4;c=d=s=1;P=o=3
	while P^C:
		a,b,c,d,s,o,P,A,B=b,s*a+o*b,d,s*c+o*d,s+o,o+2,C,0,1
		for I in Q:B*=c;A=A*a+I*B
		C=A>0
	return P
def f(n,p):
	Q=[-n];R=""
	while h([1]+Q)<1:Q=[0]+Q
	Q+=[0]*p
	for I in range(len(Q)):
		i=3;Q[I]+=3
		while h(Q):Q[I]-=1;i-=1
		R+=str(i)
	return R[:-p]+"."+R[-p:]

Try it online!
Ungolfed version:
def poly_eval_pi_pos(poly,a=0,b=4,c=1,d=1,o=3,s=1,prev=9,curr=6):
	while prev != curr:
		a,b,c,d,s,o=b,s*a+o*b,d,s*c+o*d,s+o,o+2
		prev = curr
		res_n, res_d = 0,1
		for I in poly:
			res_d *= c
			res_n = res_n*a + I * res_d
		curr = res_n > 0
	return prev
def to_base_pi(n,precision):
	poly = [-n]
	res = ""
	while not poly_eval_pi_pos([1]+poly):
		poly = [0]+poly
	poly += [0]*precision
	for index in range(len(poly)):
		i = 3
		poly[index] += 3
		while poly_eval_pi_pos(poly):
			poly[index] -= 1
			i -= 1
		res += str(i)
	return res[:-precision]+"."+res[-precision:]

Try it online!

Do you require Python 3? If 2 can be used, you can use mixed spaces and tabs.

@mbomb007 "golfs that i missed" do not include switching to an older version just for the sake of golfing :P

Then you could also use \i``.

Ruby -rbigdecimal/math, 111 103 97 bytes
->x,n{q=BigMath::PI n;r=q**m=Math.log(x,q).to_i;n.times{$><<"#{?.if-2==m-=1}%i"%d=x/r;x%=r;r/=q}}

Try it online!
Takes input number as x and desired precision as n. Outputs by printing. Makes use of the built-in BigDecimal library for arbitrary pecision PI value.

built in is explicitly prohibited

See comments to the task:
"- Does "no built-ins" include no built-ins for getting Pi?"
"- No, it means no built-in that completes or trivializes the entire task."

@LeakyNun Kirill is right. Built-ins for Pi are allowed so long as the resulting answer is correct.

Don't you have to count the bytes of the command line options? I'm not sure how that works

I'd say, not anymore as per this meta. Something in the lines of "consider this a kind of different language from plain Ruby".

Python 3 + sympy, 144 bytes
from sympy import*
def f(n,p):
	R="";O=n and int(log(n,pi));r=pi**O
	for _ in range(O+p):R+=str(int(n/r));n%=r;r/=pi
	return R[:O+1]+"."+R[O+1:]

Try it online!
Quite slow, actually.


text:
Reserved JavaScript
As of ECMAScript 2015, JavaScript has 33 reserved keywords, such as break, const and new, as well as 10 future reserved keywords, such as let and await.
Your task is to chain together the largest number of consecutive1 distinct reserved keywords2 while writing functional JavaScript code3.

Consecutive reserved keywords - reserved keywords that are separated only by whitespace and/or parentheses and/or curly braces.
Reserved keywords - any reserved or future reserved keywords as of ECMAScript 2015. Reserved keywords from older standards are excluded, a full list of allowed keywords is given below.
Functional code - your code should run (state your runtime, if necessary), eventually halt, and not throw any runtime errors.

If your code needs a specific runtime, the used reserved keywords must not be no-ops in the given environment.
List of reserved keywords

await
break
case
catch
class
const
continue
debugger
default
delete
do
else
enum
export
extends
finally
for
function
if
implements
import
in
instanceof
interface
let
new
package
private
protected
public
return
static
super
switch
this
throw
try
typeof
var
void
while
with
yield

Scoring & examples
Your score will be equal to the largest number of consecutive distinct reserved keywords.
In the case of equal scores, shortest source code in bytes wins. Commented sections and strings don't count towards reserved keywords, but count towards byte count.
// score: 3
if (true) 0; else throw function() {}
             ^------------------^
// score: 2
let foo = typeof typeof void typeof void 0;
                             ^---------^
// score: 0
/* typeof default debugger */

// score: 0, doesn't halt or debugger is no-op, depending on the environment
debugger;

Standard loopholes apply.

Sandbox discussion, for those who are interested.

I feel like this might be more interesting if you did not allow parentheses between the keywords.

Is newline allowed?

@l4m2 Yes, it's whitespace.

Now that 43-score solution exist...

@l4m2 The same 43-point solution is possible without newlines as well so perhaps I simply don't understand the point you're trying to make?

In the case of equal scores, shortest source code in bytes wins. The common solution uses 4 extra chars for each word but sometimes it can do better

Let us continue this discussion in chat.

@msh210 Thanks, I didn't know tags are used like that on PCG, updated.

43 words, 603 bytes
Uhm, is this a loophole? I have no idea how the hell this is legal JS, but it works and it uses every single keyword.
new (class await
{
    break(){}
    case(){}
    catch(){}
    const(){}
    continue(){}
    debugger(){}
    default(){}
    delete(){}
    do(){}
    else(){}
    enum(){}
    export(){}
    extends(){}
    finally(){}
    for(){}
    function(){}
    if(){}
    implements(){}
    import(){}
    in(){}
    instanceof(){}
    interface(){}
    let(){}
    package(){}
    private(){}
    protected(){}
    public(){}
    return(){}
    static(){}
    super(){}
    switch(){}
    this(){}
    throw(){}
    try(){}
    typeof(){}
    var(){}
    void(){}
    while(){}
    with(){}
    yield(){}
})

Not that familiar with JS, but... are these actually keywords when used in this context, or just strings that have the same lexical structure as keywords and are using sugar to avoid quotes?

@Leushenko  Probably the second (although I'm also not too familiar with JS at all), as they look like function names in the way they are used. Still, normally it shouldn't be possible to use these keywords as functions or class names, but Siguza still did it, while still complying to the challenge rules of only using parenthesis and brackets. A nice find to complete this challenge with all words I'd say, even though most of the other answers look more impressive for actually using the keywords AS keywords. Still +1 from me, it seems we have a winner.

Of course you can make the answer more interesting by moving some of the keywords into the function body. Why not?

@user202729 Why though? Why make it overly complexly looking when it can be done so simple? Code-golfing is usually doing something as short as possible, but I personally still prefer to keep readability and simplicity to some extend (I know, I know, this isn't a code-golfing challenge). Some examples: I prefer to use -1, i+1, i-1 above ~0, -~i, ~-i when I can, just because it's clearer to read for those who aren't too familiar with code-golfing and ~ yet. Although I will of course always use i+~j and i-~j to golf that single byte of i-j-1 and i+j+1. ;)

Yes, I could mash it further, and try to get the byte count down... a beginning like if(this)return void typeof function(){} else debugger isn't hard to come up with, but after that it gets ugly fast. And yes, this totally turns keywords into identifiers - but for some of them you have to in order to be able to use them (e.g. enum). I just took it to the extreme, but isn't that what code golfing is all about? :P

Are you... literally redefining the function of keywords?

@Magic No, supplying the name of a class-method is simply a grammatical context where literal tokens are treated as property names, even if they are reserved words. This is basically the same, semantically, as doing obj["break"] = function (){} etc.

@KevinCruijssen Because not attempting further golfing means this one   actually loses, as ties are broken by bytecount.

Save tons of bytes: Eliminate the leading spaces in front of each line

37 words
if (void this) {
  do {
    with (protected)
      for (public in private)
        typeof static instanceof new (function implements() {
          var let
          try {
            throw (class extends {} {})
          } catch (package) {
            yield
          } finally {
            debugger
          }
          return
        })()
    continue
    break
  } while (interface)
} else {
  switch (delete await) { default : 42 }
}

Keywords not used:

case requires :
const requires =
export requires strict mode
import requires strict mode
super requires constructor

I admit I laughed

It looks like typical Java boilerplate code, e.g. to calculate 1 + 2.

@EricDuminil This is the real reason it's called _Java_Script.

This is just wonderful.

@apsillers that's not a dumb thing to do at all. In fact it's preferable to using let or var. Remember that const and let have more reasonable scoping than var; the variable defined is scoped to the loop body, not the function, so if it stays constant within an iteration, then const is fine.

@Dave Yeah, I realized that I was wrong today when I was running my entry -- a const loop var is usually very good practice

43 words, 302 299 bytes
switch(void function(){for(const interface in public)do with(package)try{break}catch(private){if(typeof
this)throw yield static instanceof new class extends await{case(){return}super(){debugger}import(){}export(){}enum(){}}
else continue}finally{delete let}while(protected)var implements}){default:}

Theoretical lowerbound 277 (each two words separated by one byte)

Nice work, currently you're only missing enum.

21 24 26 words, 185 bytes
+1 2 words thanks to Arnauld, and +1 to 12Me21!
void(function(){do{with({})if(typeof true in this)throw{}instanceof new(class extends{}{})
else return delete{}
try{break}finally{yield}
continue
}while(false)})()
switch({}){case{}:{}}

Assuming I understood the challenge, this scores 24 words. The words without parentheses, brackets, and whitespace:
void function do with if typeof true in this throw instanceof new class extends else return delete try break finally yield continue while false switch case

24 words, 177 bytes
Without "true" and "false", which are apparently not keywords according to the question.
void(function(){do{with({})if(typeof{}in this)throw{}instanceof new(class extends{}{})
else return{}
try{break}finally{yield}
continue
}while(delete{})})()
switch({}){case{}:{}}

Words:
void function do with if typeof in this throw instanceof new class extends else return try break finally yield continue while delete switch case

(I accidentally deleted my comment instead of editing it, the contents were: "you can use delete{} in place of true/false, think (and just return nothing")

Ah, yes. I didn't pay much attention to that rule.

you can put case ... : or default: at the end (since : isn't allowed between keywords)

Ot you can end with for(let _;0;); for +2 words (but you can't use case anymore).

switch({}){case{}:{}} => switch({}){case{}:;}? Not know if ; is sometimes necessary

38 39
class await {}
class g extends await {
 constructor() {
  super()
 }
}
switch ({}) {
 case function(){
  for (let in public)
  do with(package){
   try{break}catch(private){
   if(typeof this)
    throw static instanceof new (class extends await {})
   else{continue}}finally{debugger}
  }while(void protected)
  var implements
  return
  yield delete interface
  const a=0
 }:
}

words from "super" to "const"
Golfed version:
class e{}class g extends e{constructor(){super()}}switch({}){case
function(){for(let in public)do with(package)try{break}catch(private){if(typeof
this)throw static instanceof new(class extends await{})
else{continue}}finally{debugger}while(void protected)
var implements
return
yield delete interface
const a=0}:}

Is it now golfing time?

I'm getting Uncaught SyntaxError: Unexpected token delete when I try to run your answer in my Javascript console on Google Chrome, How can I test if your solution is valid?

@Ferrybig I use Firefox and it works fine. I can't install new version Chrome because of system

I get this error in Firefox SyntaxError: yield expression is only valid in generators

I use ff 52.7.2

21 words
(not sure about let and await)
var await=String, let=String;
switch (await) {
    case void typeof new await instanceof let in (function()
{do{try{return this
if((class extends{}{})){}else{break}}finally{(delete {})}}while(false)})():break;
}

, = and ; are not allowed as separators.

They aren't being counted

14 15 16 Words with no brackets or newline
!function(){if(0);else do throw yield new public in void typeof this instanceof class await extends function async(){}{};while(0)}

Thank Bergi for +1

Can you make it a generator function and throw in a yield?

I tried to figure out what this does, but my head started spinning. Could you post an explanation?

I'm getting Uncaught SyntaxError: Unexpected token new when I paste inside my javascript console

@Ferrybig, replace function with function*, so it will be recognized as a generator.

43 words, 300 bytes
with(this)try{let protected}catch(package){if(delete yield)for(const interface in typeof public)do{throw implements instanceof private}while(static)else debugger}finally{switch(void new class extends function(){return}{export(){var await}import(){break}super(){continue}enum(){}case(){}}){default:0}}

More readably:
with(this)
    try {
        let protected
    } catch(package){
        if(delete yield)
            for(const interface in typeof public)
                do {
                    throw implements instanceof private
                } while(static)
        else
            debugger
    } finally {
        switch(
          void new class extends function(){return} {
              export(){var await}
              import(){break}
              super(){continue}
              enum(){}
              case(){}
          }
        ){
            default:0
        }
    }

I had to use the "reserved word as method name" to deal with

case (since I had already used default with my swtich),
export and import (since module-mode is always strict, which disqualifies with)
super (since it must be followed by a property access or placed in a constructor function), and
enum (which can never be used at all, being a reserved word with no grammatically-valid use)

My 39 solution shows super can appear in the beginning without being name, but too expensive

28 Words without brackets, 234 Bytes
Putting identifier names as method definition names was too obvious (for me at least), so I was looking for the longest consecutive distinct sequence of reserved words and whitespace in a code snippet.
I hope dead code after a return doesn't count as a loophole, but the code is still runnable if the used identifiers are declared.
function*_(){implements:{
let private
var public
return yield typeof static
delete protected
throw new interface in package
break implements
debugger
void this instanceof class await extends function async(){}{}
do
continue
while(0)}}

This exploits the fact that some of the future reserved keywords are only considered invalid in ES5.1's strict mode (apparently because engines didn't bother to block all of ES3's future reserved words so there was too much code using them out there on the web).
Similarly, the async and await tokens introduced in ES8 are only considered keywords in strict mode.

Can break and continue be there?

When I call the function, I get Uncaught SyntaxError: Undefined label 'implements', does your answer require a specific runtime?

@Nit Oops, I didn't actually call it, I only checked whether it's syntactically allowed (and then optimised prosaicism :D).

@l4m2 Oh, you're right, they can't but it's a runtime error so I didn't notice :-( Needed a bit of arbitrary reordering to work (and a block with the label).

@Bergi On Firefox it's syntax error on tio nodejs it's runtime


text:
Sum of five cubes
Given an integer, output five perfect cubes whose sum is that integer. Note that cubes can be positive, negative, or zero. For example,
-10 == -64 - 64 + 64 + 27 + 27

so for input -10 you could output [-64, -64, 64, 27, 27], though other solutions are possible. Note that you should output the cubes, not the numbers being cubed.
A solution always exists -- you might enjoy puzzling this out for yourself. It's further conjectured that four cubes suffice.

Two questions: Can we output any result, or only the smallest? For -10 another possible solution could be -1000+4574296+4410944-4492125-4492125 for example. And is it allowed to output -- or +- instead of +/- respectively (i.e. 3 = 27+-27+-125--64--64 instead of 3 = 27-27-135+64+64)?

@KevinCruijssen Any result is fine. If you mean output like --5, I'd say no, as per usual rules on outputting an expression.

@KevinCruijssen You don't have to output an expression with + signs, just the numbers.

-10 = -64 - 64 + 64 + 27 + 27 or -10 = -343 + 0 -8 +125 +216

I'm assuming repetition is allowed?

@VortexYT Yes, repetition is allowed.

Just to check: must we output one solution, or can we output several of them?

@LuisMendo Just output one.

Interesting note: 3 is not sufficient (some numbers are unrepresentable), but there are some numbers whose representability is unknown (such as 33).

Brachylog, 18 bytes
∧5~lLȧᵐ≥₁∧L^₃ᵐ.+?∧

Try it online!
Explanation
We basically describe the problem, with the additional constraint that we want the output list to be non-increasing in terms of magnitudes: this forces Brachylog to properly backtrack over all possible combinations of 5 values, instead of infinitely backtracking over the value of the last element of the list.
∧                ∧    (disable some implicit stuff)
 5~lL                 L is a list of length 5
    Lȧᵐ≥₁             L must be a non-increasing list in terms of magnitude
         ∧
          L^₃ᵐ.       The output is L with each element cubed
              .+?     The sum of the output is the input

Finding different solutions
By appending a ≜, it's possible to use this predicate to find all solutions with increasing magnitudes: for example, here are the first 10 solutions for 42

Brachylog, 11 bytes
Thanks Fatalize for saving one byte
~+l₅≥₁.√₃ᵐ∧

Try it online!
Firstly ~+ enforces that the output (.) must sum to the input. l₅ again constrains the output, dictating that it must have a length of 5. ≥₁ declares that the list must be in decreasing order (I believe that this is necessary to stop the program entering an infinite loop)
We explicitly unify this list with ., the output variable, because our next predicate will "change" the values inside the list. We then take the cube root of each value in the list with √₃ᵐ. Since Brachylog is inherently integer-based, this dictates that all the numbers in the list are cube numbers.
Finally, we use ∧ because there is an implicit . added to the end of each line. Since we don't want . to be unified with the list of cube roots, we unified it earlier on and use ∧ to stop it unifying at the end.

Python 2, 58 57 54 bytes
def f(n):k=(n**3-n)/6;return[v**3for v in~k,1-k,n,k,k]

Try it online!

-2 bytes, thanks to Rod
-1 byte, thanks to Neil

You can save 2 bytes swapping the signal k=-(n-n**3)/6;[v**3for v in~k,1-k,n,k,k]

@Rod For -(n-n**3) can you not use (n**3-n)?

@Neil yes, you can.

Python 3, 65 bytes
def f(n):k=(n-n**3)//6;return[n**3,(k+1)**3,(k-1)**3,-k**3,-k**3]

Try it online!
I mean, an explicit formula is even here (although he abstracted the construction behind an existential)

You can save exactly one byte by inverting k and rewriting your equation.  Try it online!

Why bother with repeated cubing? i.e. https://codegolf.stackexchange.com/a/161235/17360

Java 8, 178 87 73 71 65 bytes
n->new long[]{n*n*n,(n=(n-n*n*n)/6+1)*n*n--,--n*n*n,n=-++n*n*n,n}

-6 bytes thanks to @OlivierGrégoire.
Same explanation at the bottom, but using the base equation instead of the derived one I used before (thanks to @LeakyNun's Python 3 answer for the implicit tip):
k = (n - n3) / 6
n == n3 + (k+1)3 + (k-1)3 - k3 - k3
Try it online.

Old 178 bytes answer:
n->{for(long k=0,a,b,c,d;;){if(n==(a=n*n*n)+(b=(d=k+1)*d*d)+(c=(d=k-1)*d*d)-(d=k*k*k++)-d)return a+","+b+","+c+","+-d+","+-d;if(n==a-b-c+d+d)return-a+","+-b+","+-c+","+d+","+d;}}

Try it online.
Explanation:
I loop k from 0 upwards until a solution is found. In every iteration it will check these two equations:

Positive k: n == n3 + (k+1)3 + (k-1)3 - k3 - k3
Negative k: n == n3 - (k+1)3 - (k-1)3 + k3 + k3

Why?
Since n - n3 = n*(1-n)*(1+n) and then 6|(n-n3), it can be written as n - n3 = 6k.
6k = (k+1)3 + (k-1)3 - k3 - k3.
And therefore n = n3 + (k+1)3 + (k-1)3 - k3 - k3 for some k.
Source.

65 bytes: n->new long[]{n*n*n,(n=(n-n*n*n)/6+1)*n*n--,--n*n*n,n=-++n*n*n,n} (or 64 using ints for less precise results)

Jelly, 13 bytes
‘c3µ;;C;~;³*3

Try it online!
Figure out the formula independently. (x+1)3 + (x-1)3 - 2 × x3 == 6 × x.

 === Explanation ===
‘c3µ;;C;~;³*3   Main link. Input: (n).
‘               Increment.
 c3             Calculate (n+1)C3 = (n+1)×n×(n-1)÷6.
   µ            Start a new monadic link. Current value: (k=(n³-n)÷6)
    ;           Concatenate with itself.
     ;C         Concatenate with (1-k).
       ;~       Concatenate with bitwise negation of (k), that is (-1-k)
         ;³     Concatenate with the input (n).
           *3   Raise the list [k,k,1-k,-1-k,n] to third power.
                End of program, implicit print.

Alternative 13 bytes: Try it online!

‘c3µ³;;;C;~*3 should save a byte since (n^3-n)/6 = C(n+1, 3)

Octave, 47 40 33 bytes
@(n)[k=(n^3-n)/6,k,-k-1,1-k,n].^3

Try it online!
Saved 6 bytes thanks to Giuseppe, since I had forgotten to remove some old parentheses. Saved another bytes by changing the signs, thanks to rafa11111.
Uses the formula in the linked math.se post:

Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
6k = (k+1)^3 + (k-1)^3 - k^3 - k^3.

It appears to be longer if I try to solve the equation: (n-n^3)=(k+1)^3 + (k-1)^3 - k^3 - k^3 with regards to k, instead of just using the equation.

Minecraft Functions (18w11a, 1.13 snapshots), 813 bytes

Uses six functions:
a
scoreboard objectives add k dummy
scoreboard objectives add b dummy
scoreboard objectives add c dummy
scoreboard players operation x k = x n
function d
function f
scoreboard players operation x k -= x b
scoreboard players set x b 6
scoreboard players operation x k /= x b
scoreboard players set x b 1
function d
scoreboard players operation x c += x b
function f
scoreboard players set x b 1
function d
scoreboard players operation x c -= x b
function f
function d
function e
scoreboard players operation x b -= x c
scoreboard players operation x b -= x c
function c
function b

b
tellraw @s {"score":{"name":"x","objective":"b"}}

c
scoreboard players operation x b *= x c
scoreboard players operation x b *= x c
function b

d
scoreboard players operation x c = x k

e
scoreboard players operation x b = x c

f
function e
function c

"Takes input" from a scoreboard objective named n, create it with /scoreboard objectives add n dummy and then set it using /scoreboard players set x n 5.  Then call the function using /function a
Uses the formula from this math.se answer

Haskell, 43 42 bytes
p n|k<-div(n^3-n)6=map(^3)[n,-k-1,1-k,k,k]

Just the popular answer, translated to Haskell. Thanks to @rafa11111 for saving a byte!
Try it online!

You can save one byte changing the sign in the k assignment...

JavaScript (Node.js), 48 45 bytes

thanks to @Arnauld for reducing 3 bytes

n=>[n,1-(k=(n**3-n)/6|0),~k,k,k].map(x=>x**3)

Try it online!

Why |0? n**3-n must be a multiple of 6 for integer n.

MATL, 21 bytes
|_G|&:5Z^3^t!sG=fX<Y)

This tries all 5-tuples of numbers from the set (-abs(n))^3, (-abs(n)+1)^3, ..., abs(n)^3. So it is very inefficient.
Try it online!

Husk, 12 bytes
ḟo=⁰Σπ5m^3İZ

Try it online!
Tries all possible lists of 5 cubes, and returns the first one with the correct sum.
Explanation
ḟo=⁰Σπ5m^3İZ
          İZ    List of all integers [0,1,-1,2,-2,3,-3...
       m^3      Cube of each integer [0,1,-1,8,-8,27,-27...
     π5         Cartesian power with exponent 5. This returns a list of all possible
                lists built by taking 5 elements from the input list. This infinite
                list is ordered in such a way that any arbitrary result occurs at a
                finite index.
ḟo              Find and return the first element where...
    Σ             the sum of the five values
  =⁰              is equal to the input

C (gcc), 85 81 75 bytes
Saved 4 bytes and then 6 bytes thanks to @ceilingcat's re-ordering of assignments
r[5];f(n){r[1]=(n=(n-(*r=n*n*n))/6+1)*n*n--;r[3]=r[4]=-n*n*n;r[2]=--n*n*n;}

Try it online!

APL (Dyalog Unicode), 30 26 bytes
3*⍨⊢,∘(1 ¯1∘+,2⍴-)6÷⍨⊢-*∘3

Try it online!
APL translation of LeakyNun's answer.
Thanks to Adám for 4 bytes by going tacit.
How?
3*⍨⊢,∘(1 ¯1∘+,2⍴-)6÷⍨⊢-*∘3 ⍝ Tacit function
                   6÷⍨⊢-*∘3 ⍝ (n-n^3)/6 (our k)
                 -)         ⍝ Negate
               2⍴           ⍝ Repeat twice; (yields -k -k)
       (1 ¯1∘+,             ⍝ Append to k+1, k-1
     ,∘                     ⍝ Then append to
    ⊢                       ⍝ n
3*⍨                         ⍝ And cube everything

Sorry if I missed something, but: 1) since in tio there is an assignment, isn't your answer here just a snippet? 2) although you used 30 characters, since it is in unicode, isn't it using 43 bytes, as pointed in tio?

@rafa11111 No and no: APL works weirdly in TIO. The assignment in the “Code” field is actually just a shortcut to use the function in the “Input” field; it’s completely unnecessary for the actual code to work. Also, we count each character as one byte because for Dyalog APL, we use @Adám’s SBCS. I can add the link to the meta post explaining it later but I’m on mobile right now.

Oh, I see. I didn't knew about these. Thanks for explaining!

Python 3, 65 61 60 bytes
lambda N:[n**3for k in[(N**3-N)//6]for n in[N,-k-1,1-k,k,k]]

Edit: dropped some unnecessary spaces.
Edit: thanks to rafa11111's smart reordering.
Inspired by this.
Try it online!

You can save one byte using (N**3-N) and [N,1-k,-1-k,k,k]

@rafa11111 smart reordering. Thanks.

Fortran (GFortran), 53 bytes
READ*,N
K=(N**3-N)/6
PRINT*,(/N,1-K,-1-K,K,K/)**3
END

Try it online!
Fortran outgolfing Python? What's going on here?

R, 40 38 bytes
Makes use of the formula in the linked math.SE post. Down to 2 bytes thanks to Giuseppe.
c(n<-scan(),k<-(n^3-n)/6,k,1-k,-k-1)^3

Try it online!

38 bytes

Husk, 20 bytes
m^3m‼:_:→:←;K¹÷6Ṡ-^3

Try it online!
Uses the formula from this post.
Explanation
m^3m‼:_:→:←;K¹÷6Ṡ-^3  Implicit input
                Ṡ-    Subtract itself from it
                   ^3    raised to the third power
              ÷6       Divide by six
   m                   Map over the value with a list of functions:
           ;             Create a singleton list with
            K¹             the function of replace by the input
         :←              Append the function of decrement
       :→                Append the function of increment
    ‼:_                  Append the function of negate twice
m^3                    Cube the numbers of the list

x86, 41 39 bytes
Mostly straightforward implementation of the formula with input in ecx and output on the stack.
The interesting thing is that I used a cubing function, but since call label is 5 bytes, I store the label's address and use the 2 byte call reg. Also, since I'm pushing values in my function, I use a jmp instead of ret. It's very possible that being clever with a loop and the stack can avoid calling entirely.
I did not do any fancy tricks with cubing, like using (k+1)^3 = k^3 + 3k^2 + 3k + 1.
Changelog:

Fix byte count using not instead of neg/dec.
-2 bytes by not xoring edx since it is probably 0 from imul.

.section .text
.globl main

main:
        mov     $10, %ecx   # n = 10

start:
        lea     (cube),%edi # save function pointer
        call    *%edi       # output n^3

        sub     %ecx, %eax  # n^3 - n
                            # edx = 0 from cube
        push    $6
        pop     %ebx        # const 6
        idiv    %ebx        # k = (n^3 - n)/6
        mov     %eax, %ecx  # save k

        call    *%edi       # output k^3
        push    %eax        # output k^3

        not     %ecx        # -k-1
        call    *%edi       # output (-k-1)^3

        inc     %ecx
        inc     %ecx        # -k+1
        call    *%edi       # output (-k+1)^3

        ret

cube:                       # eax = ecx^3
        pop     %esi
        mov     %ecx, %eax
        imul    %ecx
        imul    %ecx

        push    %eax        # output cube
        jmp     *%esi       # ret

Objdump:
00000005 <start>:
   5:   8d 3d 22 00 00 00       lea    0x22,%edi
   b:   ff d7                   call   *%edi
   d:   29 c8                   sub    %ecx,%eax
   f:   6a 06                   push   $0x6
  11:   5b                      pop    %ebx
  12:   f7 fb                   idiv   %ebx
  14:   89 c1                   mov    %eax,%ecx
  16:   ff d7                   call   *%edi
  18:   50                      push   %eax
  19:   f7 d1                   not    %ecx
  1b:   ff d7                   call   *%edi
  1d:   41                      inc    %ecx
  1e:   41                      inc    %ecx
  1f:   ff d7                   call   *%edi
  21:   c3                      ret

00000022 <cube>:
  22:   5e                      pop    %esi
  23:   89 c8                   mov    %ecx,%eax
  25:   f7 e9                   imul   %ecx
  27:   f7 e9                   imul   %ecx
  29:   50                      push   %eax
  2a:   ff e6                   jmp    *%esi

Here is my testing version that does all the cubing at the end. After the values are pushed on the stack, the cube loop overwrites stack values. It's currently 42 40 bytes but there should be some improvements somewhere.
.section .text
.globl main

main:
        mov     $10, %ecx       # n = 10

start:
        push    %ecx            # output n

        mov     %ecx, %eax
        imul    %ecx
        imul    %ecx
        sub     %ecx, %eax      # n^3 - n
                                # edx = 0 from imul

        push    $6
        pop     %ecx            # const 6
        idiv    %ecx            # k = (n^3 - n)/6

        push    %eax            # output k
        push    %eax            # output k

        not     %eax            # -k-1
        push    %eax            # output -k-1

        inc     %eax
        inc     %eax            # -k+1
        push    %eax            # output -k+1

        dec     %ecx            # count = 5
        add     $20, %esp
cube:
        mov     -4(%esp),%ebx   # load num from stack
        mov     %ebx, %eax
        imul    %ebx
        imul    %ebx            # cube
        push    %eax            # output cube
        loop    cube            # --count; while (count)

        ret

Ruby, 43 bytes
->n{[~k=(n**3-n)/6,1-k,n,k,k].map{|i|i**3}}

Try it online!

Cubically, 51 characters, 55 bytes
⇒-6-^0+7/0»8
$F:^0%@5-7/0»8^0%@5%@5f1+8^0%@5f1-8^0%

Try it online!
Apparently MDXF forgot to implement the SBCS...

Unefunge 98, 35 bytes
j&3k:**-6/:1-\:1+\0\-::!#@_::**.37*

Try it online!
It uses the popular formula from this math.se answer.

Perl 5 -nE, 48 bytes
say$_**3for$i=($_**3-($n=$_))/6,$i,-1-$i,1-$i,$n

hat-tip

PowerShell Core, 52 bytes
$o,(1-($k=($o*$o-1)*$o/6)),(-$k-1),$k,$k|%{$_*$_*$_}

Try it online!
Uses the equation o=o^3 + (1-k)^3 + (-k-1)^3 + k^3 + k^3, where k=o^3 - o; this is a minor refactoring of the popular l=o-o^3 (with k=-l).
As a side note, the expression l=o-o^3 looks like a cat with a hurt ear.


text:
Interval Notations
Challenge:
Input:
Two integer parameters a and b (where a<b and the difference is at least 2)
Output:
Output or return this text, where a and b are filled in:
(a,b) = ]a,b[ = {a<x<b}   = {a<x&&x<b}   = a+1..b-1
[a,b) = [a,b[ = {a<=x<b}  = {a<=x&&x<b}  = a..b-1
(a,b] = ]a,b] = {a<x<=b}  = {a<x&&x<=b}  = a+1..b
[a,b] = [a,b] = {a<=x<=b} = {a<=x&&x<=b} = a..b

Challenge rules:

I/O is flexible. Can be printed to STDOUT, returned as a string/character-array, etc. Can be inputted as two integers, decimals, strings (not sure why since you need to calculate the a+1 and b-1, but be my guest..), etc.
Any amount of leading and/or trailing new-lines are allowed, and any amount of trailing and/or leading spaces for each line is allowed.
The spaces at the equal signs (including those to align them in the same column) are mandatory, spaces between the other characters are not allowed.
a+1 and b-1 are replaced with the correct values after these calculations.
You are not allowed to use ≤ instead of <=.
You are not allowed to use & instead of &&.
You are allowed to output the numbers with .0 (as long as it's consistent, and not more than one decimal zero).
You can assume a is at least 2 lower than b (in order for (a,b) to be correct).
The lines should be output in the order shown.

Example:
Input: a=-5, b=10
Output:
(-5,10) = ]-5,10[ = {-5<x<10}   = {-5<x&&x<10}   = -4..9
[-5,10) = [-5,10[ = {-5<=x<10}  = {-5<=x&&x<10}  = -5..9
(-5,10] = ]-5,10] = {-5<x<=10}  = {-5<x&&x<=10}  = -4..10
[-5,10] = [-5,10] = {-5<=x<=10} = {-5<=x&&x<=10} = -5..10

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

PS: For those who had seen this challenge in the Sandbox when it was still a kolmogorov-complexity challenge with a and b hard-coded, I've changed it to an input challenge to prevent boring hard-coded and encoded answers like we usually see with KC challenges.

So for a=5, b=6 still output (5,6) = ... = 6...5?

@l4m2 Ah.. hadn't thought about that. You can assume the a and b will always be at least 2 apart. I'll edit the challenge.

It turned out to be much more fun than I was expecting. Nice challenge!

@DigitalTrauma Sorry, but this exact order.

Stax, 74 bytes
ÉyU≤₧pΔz▀σ┬`♪•a≤☻Σ╕←k►¬╗Ö)ßâL╫§▐ƒ┼°╚íS3:Y¶7]7♂e╖à╙ô≥;M0h8♦Oún┼ë`←B╠╫║┌♂α▲╚

Run and debug it
This uses stax's string templates heavily.  Unpacked, ungolfed, and commented, it looks like this.
Y                   save second input in Y register (first is already in X)
.)].([|*            cross product of ")]" and "(["; this produces [")(", ")[", "](", "]["]
{                   begin block to map over interval delimiters
  E"`x,`y"a++       push delimiters separately, then wrap them around the inputs    e.g. "(-5,10)"
  c"(])["|t         copy last value, then replace parentheses with braces           e.g. "]-5,10["
  ih'=              push half the iteration index and "="                           e.g. 0 "="
  |;'=              push iteration parity (alternating 0 and 1) and "="             e.g. 0 "=" 0 "="
  "{`x<`*x<`*`y}"   multiply each equal sign by its occurrence, and template        e.g. "{-5<x<10}"
  c'x.x&:mR         copy last value, then replace "x" with "x&&x"                   e.g. "{-5<x&&x<10}"
  yvih xi|e         calculate final bounds offsets                                  e.g. -5 1 10 -1
  "`+..`+"          add inputs to offsets, and embed in template                    e.g. "-4..9"
  5l                combine last 5 values into array
m                   map [")(", ")[", "](", "]["] using block
:<                  left-align grid colums to add extra spaces
m" = "*             for each row, join with " = " and output

Run this one

JavaScript (ES6), 184 182 181 180 bytes
Takes input in currying syntax (a)(b). Returns an array of 4 strings.
a=>b=>[1,2,3,4].map(k=>'31,23 = 31,23 = {10x72}4{10x&&x72}45..6'.replace(/\d/g,(n,i)=>[(+n?k<3:k&1)?'<':'<=',a,b,'][)([[]('[(i*17^k*718)%9],'   = '.slice(k/2),a+k%2,b-(k<3)][n%7]))

Try it online!
How?
For each row k with 1 ≤ k ≤ 4, we start with the following template:
"31,23 = 31,23 = {10x72}4{10x&&x72}45..6"

and replace each decimal digit n at position i according to the following table:
  n  | Replaced with           | Code
-----+-------------------------+------------------------------------------
 0,7 | comparison operator     | (+n ? k < 3 : k & 1) ? '<' : '<='
  1  | a                       | a
  2  | b                       | b
  3  | interval bound          | '][)([[]('[(i * 17 ^ k * 718) % 9]
  4  | a substring of '   = '  | '   = '.slice(k / 2)
  5  | either 'a' or 'a + 1'   | a + k % 2
  6  | either 'b' or 'b - 1'   | b - (k < 3)

Python 2, 225 203 195 bytes
a,b=input()
for d in 0,1:
 for m in 0,1:k=`a`+','+`b`;o='{'+`a`+'<'+m*'=';c='x<'+d*'='+`b`+'}'+'  '[m+d:];print' = '.join(['(['[m]+k+')]'[d],']['[m]+k+'[]'[d],o+c,o+'x&&'+c,`a+1-m`+'..'+`b-1+d`])

Try it online!

m4, 194
Seems like a job for a macro processor.  Not sure if m4 meets our standards for a programming language.  It does have looping ability and arithmetic eval, so I assume its close to the mark.
define(l,`$1a,b$2 = $3a,b$4 = {a<$5x<$6b} $8= {a<$5x&&x<$6b} $8= $7')dnl
l(`(',`)',],[,,,incr(a)..decr(b),`  ')
l([,`)',[,[,=,,a..decr(b),` ')
l(`(',],],],,=,incr(a)..b,` ')
l([,],[,],=,=,a..b,)

This is my first non-trivial look at m4, so I suspect there are more golfing opportunities I've missed.
Inputs are passed using -D macro definitions at the command line.  Not sure if anything needs to be added to the score for these, as as far as I can tell this is the only way to meaningfully pass parameters:
$ m4 -Da=-5 -Db=10 intnot.m4
(-5,10) = ]-5,10[ = {-5<x<10}   = {-5<x&&x<10}   = -4..9
[-5,10) = [-5,10[ = {-5<=x<10}  = {-5<=x&&x<10}  = -5..9
(-5,10] = ]-5,10] = {-5<x<=10}  = {-5<x&&x<=10}  = -4..10
[-5,10] = [-5,10] = {-5<=x<=10} = {-5<=x&&x<=10} = -5..10 $

Try it online.

Thanks @Dennis for adding m4 to TIO so quickly!

I don't see why m4 wouldn't be a valid programming language to answer in, but what do I know. ;) As for the -D arguments it's completely fine. In my challenge description I stated I/O is completely flexible, so whether you take input as STDIN, function parameters, program command-line arguments, compiler-flags, reading a file, or whatever other input-method you can think of is completely up to you.

Python 2, 187 bytes
t=a,b=input()
for j in 1,0:
 for i in 1,0:print"%%s%d,%d%%s = "%t*2%('[('[i],'])'[j],'[]'[i],']['[j])+"{%d<%sx%%s<%s%d}%s = "%(a,'='[i:],'='[j:],b,' '*(i+j))*2%('','&&x')+`a+i`+'..'+`b-j`

Try it online!

Perl 5, 181 bytes
I thought this would have worked out a lot shorter...
$_="sd,ds = sd,ds = {dsxsd}s= {dsx&&xsd}s= d..d
"x4;s!s!("()][<<   [)[[<=<  (]]]<<=  [][]<=<= "=~s/[<= ]+/$&$&/gr=~/ +|<=|./g)[$-++]!ge;s/d/$F[$x%2]+{8,1,9,-1,19,-1,28,1}->{$x++}/ge

Try it online!
Explanation
Originally this was using a printf format string, but just having s and d was shorter when combined with s///.
First the format string is built into $_ and quadruplicated, then all ss are replaced with the corresponding bracket, <, <= or spaces, depending on the replacement index. I hoped to save some more bytes with the duplication of the last 5 chars of each block, but this only ended up saving 2 bytes. The resultant string is split up into elements of spaces, <= or single characters.
Finally all ds are replaced with the desired number which is adjusted based on the index of the current replacement via a hash key.

JavaScript, 190 189 bytes
x=>y=>`(0)7]0[7{1<x<2}  7{1<52}  73..4
[0)7[0[7{18x<26{185261..4
(0]7]0]7{1<x826{1<5=263..2
[0]7[0]7{18x82}7{185=2}71..2`.replace(/\d/g,d=>[[x,y],x,y,x+1,y-1,`x&&x<`,`}  = `,` = `,`<=`][d])

Try it online

Java (JDK 10), 251 bytes
a->b->("(a,b)q]a,b[q{a<x<b}  q{a<x&&x<b}  q"+-~a+".."+~-b+"\n[a,b)q[a,b[q{a<=x<b} q{a<=x&&x<b} qa.."+~-b+"\n(a,b]q]a,b]q{a<x<=b} q{a<x&&x<=b} q"+-~a+"..b\n[a,b]q[a,b]q{a<=x<=b}q{a<=x&&x<=b}qa..b").replace("a",a+"").replace("b",b+"").replace("q"," = ")

Try it online!
Credits

-50 bytes thanks to Kevin Cruijssen

I'm still golfing...

Almost done with golfing? I got a suggestion to remove 85 bytes. ;)

@KevinCruijssen I'm done but I removed far less than 85 bytes...

251 bytes with three boring .replace.

Yeah, basically my first solution using replace indeed, instead of formatting. Nice. Boring indeed, but nice! :-)

Python 2, 277 199 193 189 bytes
a,b=input()
for i in 4,3,2,1:x,y=i%2,i>2;e='=';p=`a`+','+`b`;print'(['[x]+p+'])'[y],e,']['[x]+p+']['[y],e,2*('{%d<%s<%s%d} %s= '%(a,e*x+'%sx',e[y:],b,i/2*' '))%('','x&&')+`a+1-x`+'..'+`b-y`

Try it online!

2*('{%d<%s<%s%d} %s= '%(a,e*x+'%sx',e[y:],b,i/2*' '))%('','x&&') -> 2*('{%d<%s%%sx<%s%d} %s= '%(a,e*x,e[y:],b,i/2*' '))%('','x&&') saves two :)

Excel, 399 bytes
="("&A1&","&B1&") = ]"&A1&","&B1&"[ = {"&A1&"<x<"&B1&"}   = {"&A1&"<x&&x<"&B1&"}   = "&A1+1&".."&B1-1&"
 ["&A1&","&B1&") = ["&A1&","&B1&"[ = {"&A1&"<=x<"&B1&"}  = {"&A1&"<=x&&x<"&B1&"}  = "&A1&".."&B1-1&"
 ("&A1&","&B1&"] = ]"&A1&","&B1&"] = {"&A1&"<x<="&B1&"}  = {"&A1&"<x&&x<="&B1&"}  = "&A1+1&".."&B1&"
 ["&A1&","&B1&"] = ["&A1&","&B1&"] = {"&A1&"<=x<="&B1&"} = {"&A1&"<=x&&x<="&B1&"} = "&A1&".."&B1

Nothing particularly interesting here.

Javascript, 273 258 232 bytes
Thanks Kevin Cruijssen for saving me 15 bytes !
e=>f=>'(j)h]j[h{a<x<b}  h{a<x&&x<b}  hc..d\n[j)h[j[h{a<=x<b} h{a<=x&&x<b} ha..d\n(j]h]j]h{a<x<=b} h{a<x&&x<=b} hc..b\n[j]h[j]h{a<=x<=b}h{a<=x&&x<=b}ha..b'.replace(/a|b|c|d|h|j/g,m=>{return{a:e,b:f,c:e+1,d:f-1,h:" = ",j:e+","+f}[m]})

Try it online
Thanks for TFeld for giving me that idea, saving around 60 bytes from my original answer.
Ungolfed :
e => f => '(j)h]j[h{a<x<b}  h{a<x&&x<b}  hc..d'
 + '\n[j)h[j[h{a<=x<b} h{a<=x&&x<b} ha..d'
 + '\n(j]h]j]h{a<x<=b} h{a<x&&x<=b} hc..b'
 + '\n[j]h[j]h{a<=x<=b}h{a<=x&&x<=b}ha..b'
.replace(/a|b|c|d|h|j/g, m=>{
        return {a:e,b:f,c:e+1,d:f-1,h:" = ",j:e+","+f}[m]
    }
)

Javascript (original answer), 340 bytes
(a,b)=>alert(`(${a},${b}) = ]${a},${b}[ = {${a}<x<${b}}   = {${a}<x&&x<${b}}   = ${a+1}..${b-1}\n[${a},${b}) = [${a},${b}[ = {${a}<=x<${b}}  = {${a}<=x&&x<${b}}  = ${a}..${b-1}\n(${a},${b}] = ]${a},${b}] = {${a}<x<=${b}}  = {${a}<x&&x<=${b}}  = ${a+1}..${b}\n[${a},${b}] = [${a},${b}] = {${a}<=x<=${b}} = {${a}<=x&&x<=${b}} = ${a}..${b}\n`)

The new-line at {a<=x&&\nx<=b} shouldn't be there, and you're missing the first (a,b) = . As for some golfing: instead of alert you can just return the result. (m)=> can be m=>. (e,f)=> can be e=>f=>. And you can use g directly instead of creating the let g=: m=>{return{a:e,b:f,c:e+1,d:f-1}[m]}. Try it online 258 bytes. And probably more can be golfed, I'm not too skilled in JS..

Well you look more skilled than I am. Thanks for the tips, i'll add them to the answer

Well, I'm mostly someone who golfs in Java (or Whitespace), and these golfing tips also apply to Java answers, which is mostly why I know them: (m)-> to m->; (e,f)-> to e->f->, and var g=new int[]{...}return g[m] to return new int[]{...}[m]. ;) Also, I've been active on this SO for little over two years now, so I've seen JS answers use these kind of things before as well.

C (gcc), 224 237 bytes
f(a,b,c,m,n,o){for(c=0;++c<5;printf("%c%d,%d%c = %c%d,%d%c = {%d<%sx<%s%d}%*s= {%d<%sx&&x<%s%d}%*s= %d..%d\n","[("[m],a,b,"])"[n],"[]"[m],a,b,"]["[n],a,"="+m,"="+n,b,o,"",a,"="+m,"="+n,b,o,"",a+m,b-n)){m=c%2;n=c<3;o=3-c/2;}}

Try it online!
Moving the "<[=]" into the format string allowed me to remove the array altogether. Also, moving printf() into the for loop saved a semicolon.
Original answer
f(a,b,c,m,n,o){char*e[]={"<=","<"};for(c=0;++c<5;){m=c%2;n=c<3;o=3-c/2;printf("%c%d,%d%c = %c%d,%d%c = {%d%sx%s%d}%*s= {%d%sx&&x%s%d}%*s= %d..%d\n","[("[m],a,b,"])"[n],"[]"[m],a,b,"]["[n],a,e[m],e[n],b,o,"",a,e[m],e[n],b,o,"",a+m,b-n);}}

Try it online!
There's nothing particularly noteworthy here: I used the usual tricks for shaving the size of the function (hoisting int autos into the function header, using K&R style, indexing into string constants.) Storing the {"<=","<"} into an array proved more size-efficient than inserting a format specifier for this challenge as it was used more than once.

216 bytes

Retina, 216 bytes
.+
$&()][<<  ¶$&[)[[<=< ¶$&(]]]<<= ¶$&[][]<=<=
((.*),(.*))(.)(.)(.)(.)(<=?)(<=?)( *)
$4$1$5 = $6$1$7 = {$2$8x$9$3}$10 = {$2$8x&&x$9$3}$10 = $2_$8..$3_$9
_<=

\d+_
$&*___
T`<`_` _+<|\.-_+<
___<
_
__<
-1
_(_*)
$.1
-0
0

Try it online! Explanation:
.+
$&()][<<  ¶$&[)[[<=< ¶$&(]]]<<= ¶$&[][]<=<=
((.*),(.*))(.)(.)(.)(.)(<=?)(<=?)( *)
$4$1$5 = $6$1$7 = {$2$8x$9$3}$10 = {$2$8x&&x$9$3}$10 = $2_$8..$3_$9

Build up the main bulk of the result.
_<=

If the variable is involved in a loose inequality, then the value is inclusive, so we can delete the placeholder.
\d+_
$&*___

Convert the value to unary and add 2.
T`<`_` _+<|\.-_+<

Remove the placeholder for a strict lower inequality or a negative strict upper inequality. It's still had 2 added, but 1 will be subtracted later, giving the desired result.
___<
_

Subtract 2 from the other non-zero strict inequalities, restoring the original value, from which 1 will be subtracted later.
__<
-1

Change a strict upper inequality of 0 to -1.
_(_*)
$.1

Subtract 1 from the remaining strict inequalities and convert to decimal.
-0
0

Fix up another edge case.

Python 3, 180 bytes:
lambda a,b:[eval('f"'+"{%r[j]}{a},{b}{%r[i]} = "*2%('([',')]','][','[]')+"{{{a}<{'='[:j]}x%s<{'='[:i]}{b}}}{'  '[i+j:]} = "*2%('','&&x')+'{a+j}..{b-i}"')for i in(1,0)for j in(1,0)]

explanation
Basically builds an f-string that is evaluated in a list comprehension.  Old-style % string interpolation is used to delay evaluating the expressions until the f-string is evaluated.
lambda a,b:[
    eval(
      'f"' +                                                            # f-string prefix
      "{%r[j]}{a},{b}{%r[i]} = "*2%('([',')]','][','[]') +              # first two terms
      "{{{a}<{'='[:j]}x%s<{'='[:i]}{b}}}{'  '[i+j:]} = "*2%('','&&x') + # second two terms
      '{a+j}..{b-i}"'                                                   # last term
      )
    for i in(1,0)for j in(1,0)
    ]

The first part of the string, 'f"', will become the prefix for the f-string.
The second part of the string builds the format string for the first two interval expressions. %r is used to save from needing to put quotes in the format, i.e., "{%r[j]}" is the same as "{'%s'[j]}".  When the f-string is evaluated, the correct bracket is selected.
The third part of the string builds the next two interval expressions.
The last part formats the "a..b" part of the f-string.
The assembled f-string looks like: f"{'(['[j]}{a},{b}{')]'[i]} = .... = {a+j}..{b-i}"
When the f-string is evaluated, all the expressions in braces {} are are replaced by their value. So,
{a} gets replaced by the value of a, and {'(['[j]} gets replaced by ( if j is 0 or [ if j is 1.

SOGL V0.12, 110 bytes
<ŗŗ}”⁴
"{ŗ<ŗx³
W}↔b ,e++Κ+²
4∫2\f»¹Aa{Ƨ[(²a{Ƨ[]²ba{ =*}eο+++:³⁴;³&&x⁴a_beh+H⁶;!+ƨ.+Κο++++}⁰№Iā;0E{┼ē4=‽"δY↑æ‘┼

Try it Here!

Python 3, 248 bytes
def f(a,b):
 l=[['(',')','[','<',1],['[',']',']','<=',0]]
 r=[0,1]
 for i in r:
  for j in r:
   print(('%s%d,%d%s='*2+'{%d%sx%s%d}={%d%sx&&x%s%d}=%d..%d')%((l[j][0],a,b,l[i][1],l[1-j][2],a,b,l[i][2])+(a,l[j][3],l[i][3],b)*2+(a+l[j][4],b-l[i][4])))

Try it online!