[Question]
      [
# Summary:
For any given language, what is the smallest amount of unique characters for your language to be [Turing-Complete](https://en.wikipedia.org/wiki/Turing_completeness)?
# Challenge:
For any language of your choice, find the smallest subset of characters that allows your language to be Turing-Complete. You may reuse your set of characters as many times as you want.
---
# Examples:
* JavaScript: `+!()[]` (<http://www.jsfuck.com>)
* Brainfuck: `+<>[]` (assumes a wrapping cell size)
* Python 2: `()+1cehrx` (made from scripts like `exec(chr(1+1+1)+chr(1))`)
# Scoring:
This challenge is scored in **characters**, not *bytes*. For example, The scores for the examples are 6, 5, and 9.
---
# Notes:
* This challenge differentiates from others in the sense that you only your language to be Turing-Complete (not necessarily being able to use every feature of the language.)
* Although you can, please do not post answers without reducing the characters used. Example: Brainfuck with 8 characters (since every other character is a comment by default.)
* You MUST provide at least a brief explanation as to why your subset is Turing-Complete.

[Answer]
# [Whispers v1](https://github.com/cairdcoinheringaahing/Whispers/tree/v1), 7 characters
```
> 1+'⍎
```
The main idea is to build an arbitrary Python expression using `+` (addition or string concat) and `'` (chr) and `⍎` (eval) it. So the proof is in two parts: constructing an arbitrary string, and making sure that Python's eval (as opposed to an arbitrary program) is Turing-complete.
### Python `eval` is Turing-complete
Unlike `exec`, we can't use many syntactic keywords like `while` and even `def`. But we have `lambda` expressions, and it turns out that we can implement untyped lambda calculus. As a minimal example, the following expression is an infinite loop:
```
(lambda a:a(a))(lambda a:a(a))
```
To make it more explicit, here are SKI combinators:
```
S = lambda l:lambda a:lambda m:l(m)(a(m))
K = lambda l:lambda a:l
I = lambda l:l
```
### `> 1+'\n` is enough to construct an arbitrary string
Now to actual Whispers code. The lines starting with single `>` are constant lines, and those with double `>>` reference other expressions using line numbers. We will only use 1, 11, 111 for constant lines, and construct the required charcodes using addition. The following sets up three numbers for the string `"123"` (charcodes 49, 50, 51):
```
> 1
> 11
>> 2+2  // 22
>> 3+3  // 44
>> 1+1  // 2
>> 5+5  // 4
>> 4+6  // 48
>> 7+1  // 49
>> 8+1  // 50
>> 9+1  // 51
```
Then we apply `'` (chr) to each of the charcodes:
```
>> '8   // "1"
>> '9   // "2"
>> '10  // "3"
```
Finally, we concat and eval them.
```
>> 11+12
>> 14+13
>> ⍎15
```
We successfully created the string `"123"` and passed it to `eval`. Now the only problem is that we used all digits to reference lines. It can be easily circumvented by inserting dummy syntactically valid lines `> 1` so that we can reference meaningful lines with repunits (so the line number `n` will be translated to the number containing `n` copies of 1):
```
> 1  // valid line 1
> 1    // from line 2...
> 1
...
> 1    // ...to line 10 are dummy lines
> 11 // valid line 11
> 1    // from line 12...
...
> 1    // ...to line 110 are dummy lines
>> 11+11 // valid line 111
...
```
### 7 chars is (likely) minimal, at least in v1
I checked the whole source code, and all one-char functions except `⍎` do not have mutable state at all. There are looping constructs like `While`, but using it alone requires at least 8 chars `> While1`. Therefore, the approach using `⍎` must be minimal (where 7-char solution is already known).
For TC-ness in Python eval, we need at least `lambd :()`, which is already 9 chars, and `chr` is definitely needed to create them without them in the source code. There is no 1-char solution to create those charcodes, and `1+` shares `+` with string concatenation. Therefore using `1+'` as the core chars is the minimal way to build a string that enables TC-ness.
I didn't read all of v2 and v3 source code, but I believe the 7-char solution is likely minimal on those too.
[Answer]
## Pyke, 5 characters
```
0h.CE
```
This is capable of producing an infinitely large number, turning it into a string and then evaluating it as Pyke code.
### Explanation of the code:
`0` - Add 0 to the stack. This is required to start a number
`h` - Increment the number before. By repeating this an arbitrary amount of times, you can create numbers that are infinitely big. Pyke supports bignums as it is written in Python, which uses them as a default.
`.C` - Turn a number into a string using the following algorithm: ([Github link](https://github.com/muddyfish/PYKE/blob/bb88fbfeabb49e576f1b9a7460b6bb7ecc4a1b02/node/chr.py))
```
def to_string(num):
    string = ""
    while num > 256:
        num, new = divmod(num, 256)
        string = chr(new) + string
    string = chr(num) + string
    return string
```
By this point, we can create an arbitrary amount of strings and natural numbers in Pyke with arbitrary values. Numbers can be created in the form corresponding to the regex `0(h)*` and strings can be created with `0(h)*.C`. They can be interweaved with each other to create an arbitrary mixture of strings and integers.
`E` - evaluate a string as Pyke code. This uses the same environment as the Pyke code already running so will share things like the input.
### Attempted proof that Pyke is Turing Complete.
One of the simplest ways of showing a language is turing complete is by implementing Brainf\*ck in it. This is probably much harder in Pyke than many other languages because it's list and dictionary operations are pretty much non-existent due to the lack of needing them in the area Pyke is designed to run in: [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'").
Firstly we create an interpreter for brainf\*ck and encode it using our algorithm above to create a number and then express that number with `0` and `h`. We then create the string containing the code to be ran in exactly the same way. If we were to leave it at that, we would have the stack as
```
string containing brainf*ck code
string containing brainf*ck interpreter
```
This means the code has to be in the opposite form as the Pyke stack is first in last out.
Now for the fun part: the brainf\*ck interpreter with a whopping 216 bytes!
```
Q~B"><ht.,".:=B;Z]1=L;W~Bo@D=c"ht"{I~c~LZ@EZ]1~LR3:=L)~c\,qIz.oZ]1~LR3:=L)~c\[[email protected]](/cdn-cgi/l/email-protection))~c"<>"{I~c"<>""th".:ZE=ZZ1_qI0=Z~L0"":0]10:=L)Z~LlqI~L~Ll"":1_]10:=L))~c\[qI~LZ@0qI\]~B~o>@~o+h=o))~c\]qI~o\[~B~o<_@-t=o)~o~BlN
```
[Try it here!](http://pyke.catbus.co.uk/?code=Q~B%22%3E%3Cht.%2C%22.%3A%3DB%3BZ%5D1%3DL%3BW~Bo%40D%3Dc%22ht%22%7BI~c~LZ%40EZ%5D1~LR3%3A%3DL%29~c%5C%2CqIz.oZ%5D1~LR3%3A%3DL%29~c%5C.qI~LZ%40.CpK%29~c%22%3C%3E%22%7BI~c%22%3C%3E%22%22th%22.%3AZE%3DZZ1_qI0%3DZ~L0%22%22%3A0%5D10%3A%3DL%29Z~LlqI~L~Ll%22%22%3A1_%5D10%3A%3DL%29%29~c%5C%5BqI~LZ%400qI%5C%5D~B~o%3E%40~o%2Bh%3Do%29%29~c%5C%5DqI~o%5C%5B~B~o%3C_%40-t%3Do%29~o~BlN&input=%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%5B%3E%2B%2B%2B%2B%2B%2B%2B%3E%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%3E%2B%2B%2B%3E%2B%3C%3C%3C%3C-%5D%3E%2B%2B.%3E%2B.%2B%2B%2B%2B%2B%2B%2B..%2B%2B%2B.%3E%2B%2B.%3C%3C%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B.%3E.%2B%2B%2B.------.--------.%3E%2B.%3E.&warnings=0)
If you want to try the code in semi-completed but editable form, [try it here!](http://pyke.catbus.co.uk/?code=29148259993606348019795473027151033981727193043657267298715298618848845029737110788889069846989671685456648828362149313315908236364663260280703313159747095711338624855008617588193311724075281427454604528769145152583515610047347294647716665608021028351862569315364394691180480784379528328135441143704516051303218258964158621837004922811934779379992687443430665022827059832349462401604993879108222437462218222077384731473190799648490050251634409611298857264044335892000836509220094188861002415662972007444505938234600526.C%22%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%5B%3E%2B%2B%2B%2B%2B%2B%2B%3E%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%3E%2B%2B%2B%3E%2B%3C%3C%3C%3C-%5D%3E%2B%2B.%3E%2B.%2B%2B%2B%2B%2B%2B%2B..%2B%2B%2B.%3E%2B%2B.%3C%3C%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B.%3E.%2B%2B%2B.------.--------.%3E%2B.%3E.%22E&warnings=0)
To convert from a string into a number, you can use the following Python code:
```
def conv(string, t=0):
    t *= 256
    t += ord(string[0])
    if len(string) != 1:
        return conv(string[1:], t)
    return t
```
The (almost) final solution can be [tried here!](http://pyke.catbus.co.uk/?code=29148259993606348019795473027151033981727193043657267298715298618848845029737110788889069846989671685456648828362149313315908236364663260280703313159747095711338624855008617588193311724075281427454604528769145152583515610047347294647716665608021028351862569315364394691180480784379528328135441143704516051303218258964158621837004922811934779379992687443430665022827059832349462401604993879108222437462218222077384731473190799648490050251634409611298857264044335892000836509220094188861002415662972007444505938234600526.C+347988125594877536659782960746628195016297572793998820340032545396642290201585760883465162681104342673776948804677730014550908920298091092232957970986553975038820683856336960474626750895815042319239692504698431493065354108813706261113333260242845055599097052304129582.CE&warnings=0)
### Explanation of Brainf\*ck interpreter
First lets separate the program into parts:
* The initialisation:

```
Q~B"><ht.,".:=B;Z]1=L; - The initialisation part
Q~B"><ht.,".:          - input.replace("><+-.,[]", "><ht.,")
                       - replace the characters in brainf*ck with some modified ones.
                       - this means we can `eval` the add and subtract bits easily.
             =B;       - set `B` to this.
                       - The `B` variable contains the instructions
                Z]1=L; - set `L` to [0]
                       - `L` contains the stack, initialised with 0
```
* The main loop:

```
W~Bo@D=c !code! ~o~BlN - The main loop
W                      - do
 ~Bo@D=c               -  c=B[o++]
                       -  the c variable is used to store the current character.
                ~o~BlN - while
                ~o     -   o
                     N -  ^ != V
                  ~Bl  -   len(B)
                       -  this stops the program running once it's finished.
```
* The instructions
	+ Increment/Decrement: `+-`

```
"ht"{I~c~LZ@EZ]1~LR3:=L) - The bit that does incrementing and decrementing
"ht"{I                 ) - if c in "ht"
        ~LZ@             -  L[Z]
                         -  `Z` contains the current stack pointer
      ~c    E            -  eval current character with ^ as an argument
                         -  returns the contents of `Z` either incremented or decremented
             Z]1~LR3:=L  - L[Z] = ^
```
* Input: `,`:

```
~c\,qIz.oZ]1~LR3:=L) - The code for output
~c\,qI             ) -  if character == ",":
      z.o            -    ord(input)
         Z]1~LR3:=L  -   L[Z] = ^
```
* Output: `.`:

```
~c\[[email protected]](/cdn-cgi/l/email-protection)) - The code for input
~c\.qI        ) - if c == ".":
      ~LZ@      -    L[Z]
          .C    -   chr(^)
            pK  -  print(^)
```
* Shift Left/Right: `<>`:

```
~c"<>"{I~c"<>""th".:ZE=Z - main part
~c"<>"{I                 - if "<>" in c:
        ~c"<>""th".:     -  c.replace("<>", "th")
                    ZE=Z -  Z = eval(char, Z)
Z1_qI0=Z~L0"":0]10:=L) - lower bound check
Z1_qI                ) - if Z == -1:
     0=Z               -  Z = 0
        ~L0"":         -  L.insert("", 0)
              0]10:=L  -  L[0] = 0
Z~LlqI~L~Ll"":1_]10:=L) - upper bound check
Z~LlqI                ) - if Z == len(L):
        ~Ll"":          -  L.insert("", len(L))
      ~L      1_]10:=L  -  L[-1] = 0
```
* The conditionals: `[`:

```
~c\[qI~LZ@0qI\]~B~o>@~o+h=o)) - Code for `[`
~c\[qI                      ) - if c == "[":
      ~LZ@0qI              )  -  if L[Z] == 0:
               ~B~o>          -     B[o:]
             \]     @         -    ^.find("]")
                     ~o+h=o   -   o = o + ^ + 1
```
- And `]`:

```
~c\]qI~o\[~B~o<_@-t=o) - Code for `]`
~c\]qI               ) - if c == "]":
          ~B~o<_       -    reversed(B[:o])
        \[      @      -   ^.find("[")
      ~o         -t=o  -  o = o - ^ -1
```
[Answer]
# [Self-modifying Brainfuck](https://soulsphere.org/hacks/smbf/), 2 characters
```
<+
```
Using these characters we can modify the end of the program in a way that it executes normal Brainfuck code.
Start by choosing the Brainfuck program, put `[>]` in the begining, that way the pointer will start where it should be. The number of bytes will be the number of `+` in the end of our code. Next we need the ascii values of the characters used in the bf code minus 43. These are how much we need to add to each `+`. For each number in our list we print `<` followed by that number of `+`, but start by the end of the list. Put everything together and it should do the same thing the bf code does.
Exemple: a bf cat `,[.,]`
It becomes `[>],[.,]`.
Now it has 8 bytes, so we should end the smbf code with `++++++++`.
The ascii values are 91, 62, 93, 44, 91,46, 44 and 93. Subtracting 43 we get 48, 19, 50, 1, 48, 3, 1 and 50.
```
50: <++++++++++++++++++++++++++++++++++++++++++++++++++
 1: <+
 3: <+++
48: <++++++++++++++++++++++++++++++++++++++++++++++++
 1: <+
50: <++++++++++++++++++++++++++++++++++++++++++++++++++
19: <+++++++++++++++++++
48: <++++++++++++++++++++++++++++++++++++++++++++++++
```
Putting this before the `++++++++` gives the final smbf code:
```
<++++++++++++++++++++++++++++++++++++++++++++++++++<+<+++<++++++++++++++++++++++++++++++++++++++++++++++++<+<++++++++++++++++++++++++++++++++++++++++++++++++++<+++++++++++++++++++<++++++++++++++++++++++++++++++++++++++++++++++++++++++++
```
[Try it online!](https://tio.run/##K85NSvv/30abZGCjbQMmydJGsibixIgC//8DAA "Self-modifying Brainfuck – Try It Online")
Execution:
```
<++++++++++++++++++++++++++++++++++++++++++++++++++  # Add 50 to the last byte of this code, now it ends with +++++++++++++]
<+                                                   # Add 1 to the byte to the left of that, now it ends with ++++++++++++,]
<+++                                                 # +++++++++++.,]
<++++++++++++++++++++++++++++++++++++++++++++++++    # ++++++++++[.,]
<+                                                   # +++++++++,[.,]
<++++++++++++++++++++++++++++++++++++++++++++++++++  # ++++++++],[.,]
<+++++++++++++++++++                                 # +++++++>],[.,]
<++++++++++++++++++++++++++++++++++++++++++++++++    # ++++++[>],[.,]
[>]                                                  # This was originally +++ ,but now it tells the pointer to go to the right until it leaves the code
,[.,]                                                # Execute the Brainfuck code
```
Here is a [GolfScript](http://www.golfscript.com/golfscript/) program where you input a Brainfuck code and it outputs a Self-modifying Brainfuck code that does the same, using only `<` and `+`.
```
'[>]'\+.,:l{'<'\)43-'+'*\}\*'+'l*
```
[Try it online!](https://tio.run/##S8/PSStOLsosKPn/Xz3aLlY9RltPxyqnWt1GPUbTxFhXXVtdK6Y2RgtI52j9/68TracTCwA "GolfScript – Try It Online")
[Answer]
# TI-Basic, 15 characters
(TI-83 Family)
```
While End(-1:ʟ→
```
Note that TI-Basic is [token-based](http://tibasicdev.wikidot.com/tokens) instead of character-based. `-` represents the subtraction symbol, not the negative sign. `)` is not needed because TI-Basic automatically closes all parentheses when it reaches a `:` or `→`. The minimum distinct tokens would be 9 tokens: `While` , `End`, `(`, `-`, `1`, `:`, `ʟ`, `→`, and any capital letter or theta.
With these characters, you can use:
* `While`  for conditional branching and looping (checks if the
expression is nonzero)
* `End` to end a `While`  loop
* `W` and `E` as number variables
* `1`, `-`, and `(` for constructing integers (e.g. `1-1` is 0, `1` is
1, `1-(1-1-1` is 2, `1-(1-1-1-1` is 3, `11-1-1` is 9, etc.) and doing
operations (`-` can be used for addition and subtraction, and `(` can be
used for implied multiplication)
* `:` for separating commands and can be replaced with a newline
* `→` to store values into number variables and into list elements
* `ʟ`, `W`, `E`, and `1` to reference lists (which can store up to 999
numbers or 99 on a TI-83); you can construct
242 possible list names from `W`, `E`, and `1`
* `(` to get an element from a list
This is Turing-complete because you can translate brainf\*ck (without `,` and `.` and with 999 or 99 cells), which is Turing-complete, with these characters:
`W` stores the position of the pointer, `ʟE` stores all the cells, and `E` is a temporary variable. The TI-83 versions use 99 cells instead of 999 cells.
| brainf\*ck symbol | Limited TI-Basic equivalent |
| --- | --- |
| (initialization) | TI-83: `111-11-1→W:While W:1-1→ʟE(111-11-W:W-1→W:End:1→W:`non-TI-83: `1111-111-1→W:While W:1-1→ʟE(1111-111-W:W-1→W:End:1→W:` |
| `+` | `1-(1-1-ʟE(W→ʟE(W:1→E:While E(1-(1-1-111-111-11-11-11-(1-1-ʟE(W:1-1→E:End:While E:1-1→E:E→ʟE(W:End:` |
| `-` | `1→E:While EʟE(W:1-1→E:E-(1-ʟE(W→ʟE(W:End:While E:1-1→E:1-(1-111-111-11-11-11→ʟE(W:End:` |
| `<` | TI-83: `1-1-(1-W→W:1→E:While EW:1-1→E:End:While E:1-1→E:111-11-1→W:End:`non-TI-83: `1-1-(1-W→W:1→E:While EW:1-1→E:End:While E:1-1→E:1111-111-1→W:End:` |
| `>` | TI-83: `1-(1-1-W→W:1→E:While E(111-11-W:1-1→E:End:While E:1-1→E:1→W:End:`non-TI-83: `1-(1-1-W→W:1→E:While E(1111-111-W:1-1→E:End:While E:1-1→E:1→W:End:` |
| `[` | `While ʟE(W:` |
| `]` | `End:` |
Here is a program that prints a list of the first 99 Fibonacci numbers:
```
1→ʟE(1:1→ʟE(1-(1-1-1:111-11-1-1-1→W:While W:ʟE(111-11-1-1-W→E:E-(1-1-ʟE(111-11-1-W→ʟE(111-11-W:W-1→W:End:ʟE
```
[Answer]
# [Zsh](https://www.zsh.org), 8 characters
```
$#< (){}
```
* `<<<string` prints `string`
* `(){body} args` is an anonymous function, which is immediately called with `args`
* `<<<$#` outputs the number of arguments to a function
* So we can use `(){<<<$#} $ $ $` to output 3 (for example)
* `${(#)var}` gets the character with the codepoint stored in `var`
* `${(#)$(command)}` gets the character with the codepoint that is the result of `command`
* We can combine these to generate arbitrary characters, e.g. `${(#)$((){<<<$#} $ $ $)}` is `\x03`
Hence, we can construct the string `eval`:
```
${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}
```
And use that to execute any arbitrary code. Here is a demonstration that outputs `Hello, World` (3311 bytes):
```
${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)} ${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}${(#)$((){<<<$#} $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjwYKlpSVpuha3eN6rVGsoa6poaGhW29jYqCjXKqgMF6hZOzz9Nlz9NZJ8iO5fhcHu4eEcJcPZb6M-He4-pbd_qW_TUI-roe7-Uf-O-npk-FSzFtLvgXZ_YN0gAA)
`$#(){}` are integral to this method, but I think there might be a way to remove  or `<`. Unfortunately I can't find one without adding a different character instead.
[Answer]
# Stacked, 5 chars
```
{!n:}
```
This is surprisingly short. If Stacked can implement each of the SKI combinations, then it is Turing Complete. Recap:
* `I` combinator - the identity function. `x -> x`
* `K` combinator - the constant function. `x -> y -> x`
* `S` combinator - the substitution function. `(x, y, z) -> x(z)(y(z))`
## I combinator: `{!n}`
Now, for the stacked specifics. `{! ... }` is an n-lambda. It is a unary function whose argument is implicitly `n`. Then, the last expression is returned from the function. Thus, `{!n}` is a function that takes an argument `n` and yields `n`.
## K combinator: `{!{:n}}`
Now, `{:...}` is a function that takes no arguments, and returns `...`. Combining this with our n-lambda formation, we get (adding whitespace for clarity):
```
{! { : n } }
{!         }   n-lambda. arguments: (n)
   { : n }     lambda.   arguments: ()
       n       yields n.
```
## S Combinator: `{n!nn!nnn:nnn{!n}!nn!nnn{!n}!n!!}`
Ok, this looks a little more complicated. So, a lambda takes arguments, separated by non-identifier characters. Thus, the lambda in the header is equivalent to:
```
{n nn nnn:nnn{!n}!nn!nnn{!n}!n!!}
```
This is a lambda that takes three arguments, `n`, `nn`, and `nnn`. Let's replace these with `x`, `y`, and `z` for clarity:
```
{x y z:z{!n}!y!z{!n}!x!!}
```
The two `{!n}!` are just identity function to again avoid whitespace, where `!` means "execute". So, again, reducing:
```
{x y z:z y!z x!!}
```
With an explanation:
```
{x y z:z y!z x!!}
{x y z:         }  three arguments
       z y!        apply `y` to `z` -- `y(z)`
           z x!    apply `x` to `z` -- `x(z)`
               !   apply `x(z)` to `y(z)` -- `x(z)(y(z))`
```
And therefore, this is the S combinator.
[Answer]
## [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), 5 characters
```
(q d)
```
Using only the macros `d`ef and `q`uote, we can implement the [S and K combinators](https://en.wikipedia.org/wiki/SKI_combinator_calculus), which [are Turing-complete](http://esolangs.org/wiki/S_and_K_Turing-completeness_proof). (Thanks to [Qwerp-Derp](https://codegolf.stackexchange.com/users/49561) for the inspiration.) Here it is all on one line:
```
(d dd (q (qq qq)))  (d dq (q ((qq) (dd (q (qqq)) (dd (q q) qq)))))  (d dqq (q ((qq) (dd (q (qqq)) (dd (q dqqd) (dd (q q) qq) (q qqq))))))  (d dqqd (q ((qq qqq) (dd (q (qqqq)) (dd (dd (dd (q q) qq) (q qqqq)) (dd (dd (q q) qqq) (q qqqq)))))))
```
The functions `dq` and `dqq` are the K and S combinators, respectively. They expect their arguments curried: i.e., for `SKK` you have to do `((dqq dq) dq)`, not `(dqq dq dq)`. `dd` is a helper function that makes a list out of its arguments (a reimplementation of the `list` function in the standard library). `dqqd` is a partially curried helper function for `dqq` that takes arguments `f` and `g` (as opposed to `dqq` that takes only `f`).
[Try it online!](https://tio.run/nexus/tinylisp#jY67DcUwCEV7pqCEUSxKr0AGIMVb37ngOIqSV0RCfA8Xhji7swQsOEJVKVtB1UNTiVkuBMCqQie/Nj6sAPLHfmWnzhLyS6lGUw1@CYKuCjoZp@Af0ZN7ze/AvJuHDafrg54/VNbwRGdTWNX79quOGMM3bNaEjKQho56xAzUMSST5lswYBw) (with some test cases that implement the `I` combinator and the argument-reversing combinator `S(K(SI))K`).
### A more readable version
```
(load lib/utilities)
(def K
 (lambda (x)
  (list (q (y)) (list (q q) x))))
(def S
 (lambda (f)
  (list (q (g)) (list (q S2) (list (q q) f) (q g)))))
(def S2
 (lambda (f g)
  (list (q (x)) (list (q S3) (list (q q) f) (list (q q) g) (q x)))))
(def S3
 (lambda (f g x)
  ((f x)
   (g x))))
```
Functions in tinylisp are simply lists with two elements: the parameters and the function body. For example, the function `((y) (q (1 2 3)))` takes one argument, `y`, and returns the list `(1 2 3)` (which had to be quoted to prevent evaluation). So to return this function from another function, we only need to build the correct list. This is what `K` does. If we pass the list `(1 2 3)` to `K`, it is bound to `K`'s parameter `x`, and we get:
```
(list (q q) x) -> literal q followed by value of x -> (q (1 2 3))
(list (q (y)) ...) -> literal (y) followed by the above -> ((y) (q (1 2 3)))
```
which is a function that takes one argument and always returns `(1 2 3)`, as desired.
`S` and its helper functions work the same way. Passing `func1` to `S` returns the list/function
```
((g) (S2 (q func1) g))
```
Passing `func1` and `func2` to `S2` returns the list/function
```
((x) (S3 (q func1) (q func2) x))
```
And finally, passing `func1`, `func2`, and `arg` to `S3` evaluates
```
((func1 arg) (func2 arg))
```
which implements the S-combinator.
To get from this more-readable form to the 5-character version, we replace the library macro `lambda` with the direct method of defining functions as lists: `(lambda (x) (expr))` -> `(q ((x) (expr)))`. We also reimplement `list` and call it `dd`:
```
(d dd    Define dd
 (q      to be this list (which acts as a lambda function):
  (qq     Take a list of variadic args qq
   qq)))  and return the arglist
```
Then it's just a matter of renaming all the functions and arguments to use only `d`s and `q`s.
[Answer]
# Java, 30 26 characters
```
 ()+-.0;=Sacdefgimnorstv{}
```
Taking a different approach from the [other (more clever) Java answer](https://codegolf.stackexchange.com/a/110789/), this one uses "regular" characters.
Java (like most languages) offers many facilities above and beyond what is required to be Turing-complete: basic arithmetic, jumps, and declaring variables (memory on the tape). The only types of jumps necessary are the simple `if` and `for` statements.
I started by writing a small program shell (`main` method), then adding statements that implement the bare minimum set that represents a Turing-complete subset of Java. I did so in a way that used the fewest characters possible, and came up with this:
```
interface S {
  static void main(String... s) {
    int r = 0;
    r++;
    int t = p;
    t--;
    if (t == 0) {
      r--;
    }
    for(;;) {
      t++;
      r++;
    }
  }
}
```
Removing all whitespace except for one space (`0x20`), sorting, and removing duplicates provides the string above.
These characters allow:
* `if` conditionals.
* Variable assignments.
* Comparing variables against each other and zero.
* `for` loops, including infinite loops (`for(;;)`)
* Adding and subtracting arbitrary numbers via repeated unary increment and decrement.
In other words, I have reduced Java to a slightly more readable version of Brainfuck.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~5~~ 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
.gBV
```
-1 distinct byte thanks to *@ovs*.
**Explanation:**
* `.g`: Pushes the amount of items currently on the stack
* `g`: Pop the current item, and push its length
* `B`: Pops the top two items on the stack, and do base-conversion
* `.V`: Pops and evaluates the top string as 05AB1E code
Using the `.g` + `g` we can create any positive number. Using `B` we can convert combinations of two numbers to a string of characters from the 05AB1E codepage. And using `.V` we can evaluate those characters as 05AB1E code.
One thing to note when creating such programs: according to [the 05AB1E source code](https://github.com/Adriandmen/05AB1E/blob/master/lib/commands/int_commands.ex), the order of the characters used in the base-conversion up to 256 is: `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzǝʒαβγδεζηθвимнт\nΓΔΘιΣΩ≠∊∍∞₁₂₃₄₅₆ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~Ƶ€Λ‚ƒ„…†‡ˆ‰Š‹ŒĆŽƶĀ‘’“”–—˜™š›œćžŸā¡¢£¤¥¦§¨©ª«¬λ®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ`. So a slightly different order than [the 05AB1E codepage](https://github.com/Adriandmen/05AB1E/wiki/Codepage) (which makes sense, since we start with digits and letters for the base-conversion).
To generate a program, we basically push loads and loads of `.g`, until the integer that is pushed is of length `255`. Then we can use one more `.g` plus the `g` to push 255, after which the `B` will convert the large integer to base-255, resulting in the program string, which we eval with `.V`.
When generating these programs, it will likely have loads of prepended no-ops (e.g. spaces, newlines, `w`, etc.), and I would advice to always add a leading `)\` as well to clean the entire stack of integers from the numerous `.g`, so implicit input and stack manipulation is available as well.
[Here a generator program](https://tio.run/##yy9OTMpM/f8/@lHDPM2Yw2v8Du961NR6eNuhlelAOjBTycUu3UkvTOnQusNrCv//NwrRBgA) given a 05AB1E program string as input, where the huge number of the output is replaced with that many `.g`, and the `D>` is replaced with one additional `.g`.
**Try it online:**
Here a few example programs using these five bytes (again, where the huge number and `D>` would then be replaced with that many `.g` in the actual program):
[Try it online: 2+2 (`YY+`).](https://tio.run/##HY89aoNhDINvVGRb/lsylJ6hewKlZMrQ@/NWX/Aigx9Jfv3dH8@fc5jTngurnKmNiliOo8rJ7EiMxLTtVGI90VUWw8mdRW2m02mcWdsAy3TQ242F2Jl0j5SdcuQ@zFpqYWCGVzaRG46QujxTJN9EoZUdY@EqtNhVHxOq7Gj0FkqehSi40VUGbWGE@VU5Ax0sIpwruMv1W@rCNdYJfN1@Pz@@z/kH)
[Try it online: Check if the input is a prime number (`p`).](https://tio.run/##HY89boNhCINvVBkwBpYMVc/QPZGqKlOG3l9febMZicc/r7/74/lzXcwuz4EpuzWhiGE7JCezItErumxaifFESRbNzumBJtPpNHaPTYCyfaipwmDZ7nSPXLvNWfdmargHA9082UROOGLV8cwl@SaE2uxoC99Cg5ntY4tudhRqBK2nEIIbfcugLIwwP5UzUEER4ZyFS77bzooSaRrp6/b7@fF9XWb/)
[Try it online: Print "Hello, World!" (`”Ÿ™,‚ï!`).](https://tio.run/##HY87bkNBDANvFFAS9WtcBDlDehsIAlcucn9s@NxphR1y9Pq7P54/5zCnPRdWOVMbFbEcR5WT2ZEYDdO2U4n1RFdZDCd3FrWZTqdxZm0DLNOH3m4sxM6ke6Ti1KP0YdZSDwZmeHUTueEITVdmiuSbKLS6YyxcQotd@ZhQdUejt1DKLETBjS4ZtIUR5pdyBjpYREgbWrsrokJQu66h4ev2@/nxfc4/)
[Answer]
# [Baba is You](https://en.wikipedia.org/wiki/Baba_Is_You), 18 characters
*Plus 3 objects in the game.*
```
TEXISMOVLPDWNFRGHY
```
A [Rule 110](https://en.wikipedia.org/wiki/Rule_110) implementation can be made with only these characters. This is based on [This writeup](https://www.twitlonger.com/show/n_1sqrh1m) by [Matthew Rodriguez](https://twitter.com/mattar0d/).
[![Screenshot of the level design](https://i.stack.imgur.com/RVPYK.png)](https://i.stack.imgur.com/RVPYK.png)
All the rules and explanation:
```
--- Always Active Rules ---
TEXT IS MOVE   - Makes the 'IS' move.
MIRROR IS TELE - When 'IS' moves into the mirror, it teleports to the other
                 mirror, like a `for` loop.
PIPE IS STOP   - Prevent text other than 'IS' from moving.
--- Rules that are activated once in a loop ---
ME           (IS) LOVE/PIXEL
MOON         (IS) IT/TILE    - 'ME' and 'MOON' are construction objects,
                               and together they represent the value
                               1. Each cycle, they turn to three probes
                               ('LOVE', 'IT', 'TILE') and a visual object
                               ('PIXEL').
LOVE/IT/TILE (IS) MOVE/DOWN  - The three probes move down, ready to create
                               the next generation according to Rule 110.
IT           (IS) MOVE/LEFT  - 'IT' moves to the left, representing xx1.
TILE         (IS) MOVE/RIGHT - 'TILE' moves to the right, representing 1xx.
                               'LOVE' stays, representing x1x.
LONELY LOVE  (IS) LINE       - 'LOVE' without 'IT' or 'TILE' represents a
                               010 pattern, which results in 'LINE' which
                               represents the value 1.
LONELY IT    (IS) LINE       - 'IT' without 'LOVE' or 'TILE' is the 001
                               pattern which results in 1.
LOVE ON IT   (IS) VINE
IT ON VINE   (IS) EMPTY      - Create 'VINE' which represents x11 where
                               we do not know the value of x yet.
VINE ON TILE (IS) EMPTY      - 111 results in 0.
LONELY TILE  (IS) EMPTY      - Remove the tile as well.
VINE/TILE    (IS) LINE       - Any remaining 'VINE' is 011, which results
                               in 1. Any remaining 'TILE' is either 101 or
                               110, which both result in 1 as well.
LOVE/IT      (IS) EMPTY      - Clean up any remaining probes.
LINE         (IS) ME/MOON    - Turns 'LINE' into construction objects.
```
Here is a screenshot of the initial state of the level.
[![Level initial state](https://i.stack.imgur.com/1O1ZO.png)](https://i.stack.imgur.com/1O1ZO.png)
[Answer]
# APL, 9 characters
```
⍎⎕UCS(≢⍬)
```
Why this is Turing-complete:
* `≢` is length, `⍬` is the empty list, and a list can be expressed simply by naming its elements, i.e. `⍬⍬⍬` is a list of three empty lists. This way, all numbers can be formed. `≢⍬` is `0`, `≢≢⍬` is `1`, and from then on `≢⍬⍬⍬...` is `N`, where `N` is the amount of `⍬`s.
* `()` are used to change evaluation order. List construction works with anything, so this way `(≢⍬)(≢⍬⍬)(≢⍬⍬⍬)` evaluates to `[0,2,3]`.
* `⎕UCS` gives a string of Unicode characters given a list of numbers. We can now generate any text we want.
* `⍎` is evaluate.
[Answer]
## ARM7 assembly - 8 bytes
```
CRS15,
```
And space and newline
With these characters, one can construct the following:
* Registers R1, R5, and R15 (R15 is the instruction pointer)
* The instruction RSC (Reverse Subtract with Carry)
* The condition code CC (do if carry clear)
* Any decimal number consisting of the numerals 1 and 5
These allow for data manipulation (subtract two registers), memory manipulation (specify destination as an address made up of 1s and 5s), and conditional jumping (R15 as the destination of a subtract with a condition code).
Comma, space, and newline are syntactic requirements of assemblers and cannot be avoided (in most cases).
One may be apt to point out that ARM does not have infinite pointers, and thus cannot be Turing complete. True, however no computer is Turing complete, and all of these languages are limited by their implementation. It is entirely possible to extend the ARM specification to allow for larger addresses. Ultimately, you'd have to let this one slide, and assume the best for the challenge.
Also, I admit to not knowing the minimum version of ARM this works in; I picked the one I know works
[Answer]
## PowerShell, ~~15~~ 14 characters
```
+[char](1)|iex
```
*Thanks to @Erik-the-Outgolfer for seeing that we don't need the `"` marks.*
I'm reasonably confident this is the smallest set we can have. Similar to the Python answers, this constructs up a program one character at a time (via things like `[char](1+1+1+1+1...+1+1)` to get the appropriate ASCII value) and then evaluating the string via `|iex`. For example, [here](https://tio.run/nexus/powershell#@x@dnJFYFKthqE0x1NSmnln0gEPNvSPRR6O@HRz@pZbd1PQDbcODVqbTNxaHZhjR3z7NmszUiv//AQ "PowerShell – TIO Nexus") is an example program that is equivalent to `"Test: "+(3+4)`. As a result, we can construct literally any PowerShell program with this method, and this is therefore Turing-Complete.
[Answer]
# Binary Lambda Calculus, Binary Mode, 3 characters (ascii-encoded)
```
HR.
```
Interpreted as incomplete segments of Binary Lambda Calculus, writing `\` for lambda, `*` for application and [De Bruijn indices](https://en.wikipedia.org/wiki/De_Bruijn_index) for variables:
```
H = 01001000 = * \ 1 \
R = 01010010 = * * \ 1
. = 00101110 = \ 1 3
```
Suppose `x` and `y` are valid terms.
Then,
```
  H x
= * \ 1 \ x
= \ x
  R x y
= * * \ 1 x y
= * x y
  R .
= * .
= * \ 1 3
= 3
```
Thus we can use `H` as `\`, `R` as `*`, and `R.` as `3`.
For `2` and `1`, suppose we have any valid term `z`.
Then,
```
* \ 3 z = 2
* \ 2 z = 1
```
(Free variables get decremented in beta-reduction with De Bruijn indices)
As for the choice of `z`, we can use `z = \ \ \ 3` (or if we allow free variables in our program, we can just use `3`).
Finally, to show we don't need more than 3 variables, we can implement [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus):
```
I = \ 1
K = \ \ 2
S = \ \ \ * * 3 1 * 2 1
```
Written using our 3 characters, these are
```
I = HRHRHR.HHHR.HHHR.
K = HHRHR.HHHR.
S = HHHRRR.RHRHR.HHHR.HHHR.RRHR.HHHR.RHRHR.HHHR.HHHR.
```
Which can be applied to each other in arbitrary ways using `R`.
[Answer]
# Scala, 12 chars
```
(),:;=>[]def
```
Using these characters, you can encode the SKI calculus.
I replaced the semicolons with newlines for readability:
```
def>[d,e,f]:(d=>(e=>f))=>(d=>e)=>(d=>f)=(dd:d=>e=>f)=>(ee:d=>e)=>(ff:d)=>dd(ff)(ee(ff))
def>>[d,e]:d=>e=>d=(dd:d)=>(ee:e)=>dd
def>>>[d]:d=>d=(>[d,d=>d,d])(>>[d,d=>d])(>>[d,d])
```
(Ab-)using the fact that you can call a method `>`, which will be seperated from the `def` by the parser to save the space.
Borrowed from [here](https://gist.github.com/othiym23/1034029) and optimised for this challenge.
[Answer]
# ARM assembler (gas), ~~14~~ 12 chars
Newline and space are included.
```
 bdlrst:[],
```
This gives us exactly what we need for Turing completeness without self modifying code:
* 3 registers: `sl` (`r9`), `sb` (`r10`), and `lr`, the minumum for RISC without immediates
* Subtraction via `rsb`. Note that this is *reversed* subtraction, so it is `x = z - y`.
* Conditional branching via `rsbs`/`tst` and `bls`/`blt` (as well as conditional instructions)
* Arbitrary value generation by `ldr(s)b reg,label` and using encoded branch offsets (see below). Can generate [-128,255].
* Virtually unbounded memory storage via `ldr` and `str`, something [the other ARM answer](https://codegolf.stackexchange.com/a/111256/94093) didn't *address* (pun intended).
Even though we only have subtraction and shifting and no immediates, what we can do is read the encoding of a branch instruction, using only labels.
`b` encoding
```
 31 30 29 28  27 26 25 24 23 22 21 20 .... 0
[   cond    ][1][0][1][0][ (offset - 8) / 4 ]
```
(The offset - 8 is a weird quirk where `pc` actually points two instructions ahead).
For example:
```
foo:
     b       next
     nop
     nop
next:
```
will be encoded as so (ARM instructions are little endian):
```
00000000 <foo>:
   0: 01 00 00 EA   b       <foo+0x8> // imm = #4
   4: 00 00 A0 E1   nop               // (mov r0, r0)
   8: 00 00 A0 E1   nop               // (mov r0, r0)
```
Therefore, if we wanted to get the value `1` into `sl`, we could do this:
```
    ldrb  sl, get_one
get_one:
    b     next // (pc + 4), [01]00 00 EA
    (not executed)
    (not executed)
next:
```
Similarly, `-1` can be done like so:
```
    ldrsb sl, get_minus_one
get_minus_one:
    b     next // (pc - 4), [FF]FF FF EA
next:
```
Therefore, to prove Turing completeness, here is a Brainfuck prologue and translation. Labels are given readable names, but in actual code it would be a bunch of `bdlrst` gibberish and there will be no comments. I/O is done by read/write to a magic port of address 0.
*While this must be in a RWX section to initialize the tape, the instructions that will be overwritten will not be executed, therefore it does not count as self modifying code. The only requirement when assembled is that `pc` is set to the first instruction.*
```
///// Prologue
prologue:
        // tape setup
        bl      tape_end            // jump to end of tape, set lr to first cell
        rsb     sb, sb, sb          // nop
tape_start:
        // 8160 filler instructions to be overwritten
tape_end:
        // code starts here
get_one:
        b       next                // [01]00 00 EA
get_7:
        b       <get_7+36>          // not writing that label
get_minus_one:
        b       next                // [FF]FF FF EA
next:
        // clear tape
        ldrb    sb, get_minus_one   // sb = 255 (zero extended)
        ldrb    sl, get_7           // sl = 7
        lsl     sb, sb, sl          // sb = sb << sl = 255 << 7 = 32640
clear:
        ldrsb   sl, get_one         // sl = 1
        rsbs    sb, sl, sb          // sb = sb - 1, set flags
        rsb     sl, sl, sl          // sl = sl - sl = 0
        strb    sl, [lr, sb]        // store 0
        bls     end_clear           // if zero, jump to end of clear loop
        b       clear
end_clear:
///// Instruction translation
// >
        ldrsb   sl, get_minus_one   // sl = -1
        rsb     lr, sl, lr          // lr = lr - sl (lr = lr + 1)
// <
        ldrsb   sl, get_one         // sl = 1
        rsb     lr, sl, lr          // lr = lr - sl (lr = lr - 1)
// +
        ldrb    sb, [lr]            // load cell from tape
        ldrsb   sl, get_minus_one   // sl = -1
        rsb     sb, sl, sb          // sb = sb - sl (sb = sb + 1)
        strb    sb, [lr]            // store cell to tape
// -
        ldrb    sb, [lr]            // load cell from tape
        ldrsb   sl, get_one         // sl = 1
        rsb     sb, sl, sb          // sb = sb - sl (sb = sb - 1)
        strb    sb, [lr]            // store cell to tape
// [
loop_start:                         // label for start
        ldrb    sb, [lr]            // load cell from tape
        rsb     sl, sl, sl          // sl = sl - sl = 0
        rsbs    sb, sl, sb          // sb = sb - sl (sb = sb - 0), set condition codes (TST will not set C flag)
        bls     loop_end            // If sb was zero, the "lower or same" cond will be set, jump to end
loop_body:
// ]
        b       loop_start          // Jump to beginning of loop
loop_end:                           // Label for end
// .
        rsb     sl, sl, sl          // sl = nullptr
        ldrb    sb, [lr]            // load from tape
        strb    sb, [sl]            // store to I/O port
// ,
        rsb     sl, sl, sl          // sl = nullptr
        ldrb    sb, [sl]            // load from I/O port
        strb    sb, [lr]            // store to tape
```
# Literally every GAS dialect, 9 chars
Again, newline and space
```
 01.bety
```
The boring answer which allows encoding ANY opcode manually using `.byte 0b10101010`.
[Answer]
## PHP 7, 5 characters
```
(^.9)
```
<https://github.com/arxenix/phpfuck>
# How it works
* `9^99` -> `106`
	+ use xor to generate numbers
* `(9).(9)` -> `'99'`
	+ use `.` to concat numbers into strings
* `'09'^'1069'^'99'` -> `'80'`
	+ xor 2 strings to get a string
* `'80'^0` -> `80`
	+ (ab)use type juggling to cast a string to an int
* Using a combination of the above tricks, you can get all of the digits 0-9
* Can construct any string `/[0-9]+/` by concatenating digits
* Can obtain any number by casting to int
* Constructing arbitrary strings requires a bit more work...
	+ `(99999999999...)` -> `INF`
		- 309 9s gives us `INF`
	+ `(INF).(9)` -> `'INF9'`
		- Can now obtain char values in `/[a-zA-Z]/` range!
		- e.g. `'INF9'^'00'^'33'^'99'` -> `'st'`
	+ the only primitive we have for initially obtaining strings is concat, which gives us a length-2 string
	+ we can generate `/[a-z]{2,}|[A-Z]{2,}/` , but getting single-character strings is not possible
* `'funcname'(param)`
	+ call functions by simply calling their string name
	+ function names are case-insensitive
* `strtok(0)` -> `false`
	+ call strtok on a number to get `false`
	+ `=== ('st'+'rt'+'OK')(0)`
* `(9).false` -> `'9'`
	+ concat number with `false` to get a length-1 string
* `'rw'^'99'^'9'` -> `'r'`
	+ extract first char of any string with xor
* Can now build arbitrary strings `/[a-zA-Z]/`
* `'CHr'(num)`
	+ generate other characters (e.g. spaces)
* Can now build any string at all! `/.*/`
* `str_getcsv("a,b")` -> `["a", "b"]`
	+ create string arrays by parsing a CSV
* `func(...["a", "b"])`
	+ use spread operator to pass multiple arguments to a function
* `create_function("", "PAYLOAD")()`
	+ use `create_function` to create a function w/ arbitrary PHP code and then call it
* Final payload looks like: `'create_function'(...str_getcsv(',"$PAYLOAD"'))`
# Previous Work
[PHPFuck](https://github.com/splitline/PHPFuck) by splitline - using 7 different characters `([+.^])`
[Answer]
## [Nock](http://urbit.org/docs/nock/definition/), 6 characters
```
[ ]012
```
Nock is a minimal virtual machine based on combinator reduction. It's memory model is a binary tree of bignums, and the [spec](https://github.com/urbit/urbit/blob/master/Spec/nock/5.txt) gzips to 340 bytes. There's a trivial transformation from Nock operations to the SKI combinators, which I stole from the Urbit [examples library](https://github.com/urbit/examples/blob/master/libs/ski/lib/ski.hoon) (which seems to originate from [this](https://www.reddit.com/r/urbit/comments/4t24bp/ski_calculus_to_nock_compiler_ski15fyr/) reddit discussion):
```
S = [[1 1 2] [1 0 1] [1 1] 0 1]
K = [[1 1] 0 1]
I = [0 1]
```
A more interesting way to do this would be to re-compile Nock with the Nock 4 operator, which is increment, to create the other operators. `[4 1 1]` is 2, `[4 4 1 1]` is 3, etc. S could alternatively be defined `[[1 4 1 1] [1 0 1] [1 1] 0 1]`, for example. I think that you still need a non-synthesized 2 operator in order to apply functions and reduce the 4, though.
[Answer]
## [Tildehyph](https://github.com/Tygrak/Tildehyph-lang), 2 characters
```
~-
```
The language uses only two characters a tilde and a hyphen. The easy answer why Tildehyph is Turing-complete is the fact that there is a [Brainfuck interpreter](https://github.com/Tygrak/Tildehyph-lang/blob/master/brainfuck.%7E-) created in it and Brainfuck is proven to be Turing-complete.
[Answer]
# [Unlambda](https://en.wikipedia.org/wiki/Unlambda), 3 characters
```
sk`
```
It's a turing tarpit of course.
[Answer]
## [BitCycle](http://esolangs.org/wiki/BitCycle), 8 characters
```
AB>/+~
```
plus space and newline.
My first demonstration of BitCycle's Turing-completeness was a [Bitwise Cyclic Tag interpreter](http://esolangs.org/wiki/BitCycle#Computational_class). But it turns out I can avoid quite a few extra characters by instead constructing a reduction, this time from a [cyclic tag system](http://esolangs.org/wiki/Cyclic_tag_system).
Consider any cyclic tag system, which consists of an ordered list of *productions*: strings of 0's and 1's (possibly including the empty string). Encode it as a string of 0's, 1's, and semicolons, with a semicolon following each production. For instance, the example from the Esolangs article, with productions (011, 10, 101), would be represented as `011;10;101;`. Then translate each element to a block of BitCycle instructions as follows:
**0**
```
    >>      ~
     +~ ~
  > +
    > ~
        > A~
B /    ~   >>
   +   ~    ~
```
**1**
```
    >>      ~
     +~ /
  > +
    > ~
      >   A~
B /    ~   >>
   +   ~    ~
```
**;**
```
    .
B / >
    .
```
(The `.` characters here are placeholders and don't affect the function of the program. They should be replaced with spaces in the actual reduction.)
Concatenate these blocks side-by-side according to the three-character representation of the cyclic tag system. Then wrap the concatenation in this looping construct:
```
> ... ~
~     ~
```
where `...` represents the rest of the program, the `>` is on the same line as the `B` collectors, and the `~ ~` don't have anything but spaces in between them.
To test this, insert a `?` before the `>` in the wrapper and give the input string as a command-line argument. For example, here's the cyclic tag system `1;0;`:
```
       >>      ~           >>      ~
        +~ /                +~ ~
     > +                 > +
       > ~                 > ~
         >   A~                > A~
?> B /    ~   >> B / > B /    ~   >> B / > > ~
 ~                                           ~
       1           ;       0           ;
      +   ~    ~          +   ~    ~
```
I will add a detailed explanation if people are interested--just leave a comment. Right now it's past my bedtime. :)
[Answer]
# J language, 7 char
To acheive Turing completeness, J can make do with the following 6 characters, plus space.
```
".u:1b
```
`1b` is a prefix for numbers meaning they are expressed in unary, so that e.g. `1b1111 1b11` is the array `4 2`. This can represent every positive integer.
Then, `u:` converts ASCII character codes to characters, and `".` evaluates a string as J code. This allows full access to the language.
## Is this minimal?
Probably. What I have is pretty darn lean.
No proper subset of these characters is sufficient, though there are a couple of equivalent sets like `do u:1b` and `".1b {a`.
J has no good facilities for doing something overly clever like embedding some lambda calculus or tag system, either, so I don't think a different strategy has a better shot, but I won't rule out the chance that I'm overlooking something sneaky.
[Answer]
# [///](http://esolangs.org/wiki////), 2 characters
```
/\
```
It was proven Turing Complete when someone wrote a Bitwise Cyclic Tag [interpreter](http://oerjan.nvg.org/esoteric/slashes/bct.sss) using it.
Shortened to 3 characters thanks to @Leo and @ETHproductions.
Shortened to 2 characters thanks to @ØrjanJohansen
[Answer]
# C (gcc), 19 bytes
```
main*fort(){}-=1[];
```
My implementation is Turing-complete because it can emulate another Turing-complete language.
32-bit cell Brainfuck interpreter (no I/O) using the commands as UTF-32 characters from the first command-line argument:
```
itr;nat;arr[111111-11111];rra=111-11-1-1-1-1-1-1-1;ora=111-11-1-1-1-1-1-1-1-1-1;aro=111-11-11-11-11-1-1-1-1-1-1-1;rar=111-11-11-11-11-1-1-1-1-1;min=111-11-11-11-11-11-11;aff=111-11-11-11-11-11-11-1-1;main(i,a)int**a;{for(i-=1;a[1][i];i-=-1){if(a[1][i]==aff)arr[itr]-=-1;if(a[1][i]==min)arr[itr]--;if(a[1][i]==aro)itr--;if(a[1][i]==rar)itr-=-1;if((a[1][i]==ora)*(arr[itr]==1-1))for(nat=1;nat;){i-=-1;nat-=-(a[1][i]==ora);nat-=a[1][i]==rra;}if((a[1][i]==rra)*(1-(arr[itr]==1-1)))for(nat=1;nat;){i-=1;nat-=-(a[1][i]==rra);nat-=a[1][i]==ora;}}}
```
aff is `+`.
min is `-`.
aro is `<`.
rar is `>`.
ora is `[`.
rra is `]`.
Note that I can't figure out how to run it yet but it should theoretically work.
[Answer]
# [Setanta](https://try-setanta.ie/), 14 characters
```
adghimnort(){}
```
Provides a way to encode the [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus) as shown:
```
i := gniomh(g){toradh(g)}
k := gniomh(g){toradh(gniomh(n){toradh(g)})}
s := gniomh(g){toradh(gniomh(n){toradh(gniomh(i){toradh(g(i)(n(i)))})})}
```
Then inline `i`, `k`, and `s` as needed.
[Answer]
# 80386 machine code, 10 bytes
```
4c 44 fe 24 04 0c 0f 85 90 c3
```
We are assuming an environment where the system `call`s this program with plenty of stack space accessible by decrementing `esp`, and a `ret` with the initial `esp` will end this program. At start, `esp` will hold the address to return. A predefined size of data stored upwards from `esp + 4` will be the input, and a predefined size of data stored downwards from `esp - 1` will be the output.
Since Brainfuck is turing complete, implementing a Brainfuck-style computing model will also be turing complete. The following Brainfuck operators can be easily translated.
```
>  dec esp        ; 4c
<  inc esp        ; 44
+  inc byte [esp] ; fe 04 24
-  dec byte [esp] ; fe 0c 24
```
Brainfuck has `[` and `]` for looping and conditional branching. To implement `]`, we first need to compare the stored value to zero.
```
inc byte [esp]
dec byte [esp]
```
This is a nice trick from @Bubbler that effectively does a compare-to-zero. Sometimes, you can also omit the comparison right after a `dec`.
80386 has two conditional jumps when the zero flag was not set.
```
jnz rel8  ; 75
jnz rel32 ; 0f 85
```
While `jnz rel8` has a shorter encoding, I'm not sure if it's enough to make the program turing complete, so we are instead using `jnz rel32`. Then, the relative offset can really be any byte without care, so we need,
```
nop ; 90
```
to pad the code so that the relative offset only consists of the usable bytes.
Finally to end the program,
```
ret ; c3
```
---
Here is an example program that takes two non-zero numbers as input, and outputs the sum.
```
sum:
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
.loop0:
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    inc byte [esp]    ; fe 04 24
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
    dec byte [esp]    ; fe 0c 24

    ; A LOT of `nop`s ; 90

    jnz .loop0        ; 0f 85 fe fe fe fe
    inc esp           ; 44
.loop1:
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    inc byte [esp]    ; fe 04 24
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
    inc esp           ; 44
    dec byte [esp]    ; fe 0c 24

    ; A LOT of `nop`s ; 90

    jnz .loop1        ; 0f 85 fe fe fe fe
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    dec esp           ; 4c
    ret
```
[Answer]
# [Emmental](https://esolangs.org/wiki/Emmental), 3 characters
```
#5?
```
Every character can be represented with these characters and '?' can execute them. For example, a program printing 'H':
```
##5#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555??#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?###5#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555??##5#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555??#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555??#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555?#5#555??
```
[Try it online!](https://tio.run/##S83NTc0rScz5/19Z2RQETU3tyaXsKdRPDEUNV1LDo5R7hWL9//8DAA)
[Answer]
# [Knight](https://github.com/knight-lang/knight-lang), 4 characters
```
EA1+
```
Similar to many other answers here, the plan is to build a string representing Knight code using `ASCII`, `1`, and `+`, and then use `EVAL` to run the resulting string as Knight code.
To build the string, we will build each individual character with `A`, `1`, and `+`. Then, we will concatenate each character together using `+`.
To build each character, we can simply just keep adding combinations of `111`, `11`, and `1` until the desired codepoint is reached, which we can then use `A` to convert the codepoint to a character. Though you may notice that if you actually tried to create a number with just `+` and `1`, you will need to include a space between at least one of the pairs of operands. For example, to create a `!`, you will have to do `A+11+11 11`; if you removed the space, then `1111` will be treated as a single number and you won't have enough arguments for one of the `+`'s.
To bypass that problem, we will take advantage of coercion. By adding a number with `ASCII 1` (making sure the number is the first argument), `A1` will be coerced to `0`, which will not affect the sum. The reason for using `A1` is to remove the need for spaces in the code. We can add all the numbers together as usual, but we will add one extra `+` at the end, which adds a number (`1`, `11`, `111`) to `A1`. But because `1` and `A1` can be differentiated as two different values without a space, we can write, for example, `+1A1` instead of `+1 A1`. Now, to create a `!`, you can do `A+11+11+11A1`.
Now that we have a strategy for building any character, we can now go on to concatenate all of them together into one string using `+`. We can do so with the following template (parentheses are just for formatting purposes):
```
(+ ... +) (A+...+1A1) (A+...+1A1)...
```
Then we can put `E` at the beginning to `EVAL` the string.
One final thing to note is the event that there is only one character in the string. Then we might have something like `EA+11+11+11+11+1+1+1+1A1` for evaluating `0`, but `EA` will be parsed as one function instead of two, so it might look like we need a space there. But we can simply concatenate a whitespace character like a space, which fixes the problem.
Here some Python code which can convert any inputted Knight code into equivalent Knight code using only the characters `EA1+`: [Try It Online!](https://tio.run/##TY6xagMxDIZ3PYUQBOy6JVW6lBYPGToUAlkKGa6mwyWhgsM@zs7Qpa9@keMEMtjoQ///2eNf@U3x5XWc5jmjR4njqRgLcsThEE226D3yG2BG55G@C8GgsS5Ne9NbPKYJey1hDtCn/UFX9EGQTkU1P4PkUsMBai7W3KCqu63zXReXS2Z@jAu969gmPSFAk@rLpv3miS0@IDm6GDfVeGdTN94KtCZ0uOmew6WgxsZ844arK1aiNRPAOEkspmrsPL97@ecdfy68OPlayVbO)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 3 characters
```
`/¢
```
This answer has been several months in the making. I've spent a lot of time trying to find a 3-character Turing-Complete subset of Vyxal, and honestly this answer was somewhat obvious.
As I showed [here](https://codegolf.stackexchange.com/a/264467/100664), the Vyxal builtin `¢` on its own is Turing-Complete, as it can interpret a variant of [Thue](https://esolangs.org/wiki/Thue). However, that answer takes input in a very specific format; here we need to construct the input within the program itself.
Essentially, `¢` takes two lists of strings and a string to perform replacements on, and repeatedly applies replacements until the string doesn't change, which is sufficient for Turing-Completeness provided the strings are sufficiently complex. Thue requires at least two different symbols to be Turing-Complete (then arbitrarily many symbols can be generated by concatenatng the two).
So, we need some way to construct arbitrary strings / string lists that contain more than two distinct symbols. That's what the other two characters are for. ``abc`` delimits a string of characters `abc`, and `/` splits a string by another string. By splitting by a constant string (which then can't be used) we can construct arbitrary sets of rules. There's just one snag.
As I said before, Thue needs to have two distinct symbols to be Turing-Complete. However, in strings we can only have the symbols `/¢`, and we need to use one to split by. This is further complicated by that, in strings, Vyxal decompresses non-unicode characters into common words and expressions - `¢¢` becomes `eyes` and `¢` becomes `[^aeiou]`. For the sake of simplicity I'm just going to use `¢¢` and pretend `¢` doesn't exist.
In short, we need to construct three symbols out of `/` and `¢¢`, such that no concatenation of any of them can contain any of them, ensuring they can be concatenated without causing problems. I came up with the set `//¢¢//`, `¢¢¢¢/¢¢¢¢`, `¢¢/¢¢/¢¢`, although something simpler probably exists.
With all of that, we can create arbitrarily complex replacement systems and emulate the behaviour of any Thue program, which is sufficient for Turing-Completeness! To do so, we push an initial string containing some combination of `¢¢¢¢/¢¢¢¢` and `¢¢/¢¢/¢¢`, then two sets of rules containing some combination of `//¢¢//`, `¢¢¢¢/¢¢¢¢`, `¢¢/¢¢/¢¢` and split them by `//¢¢//`, then simply run `¢`. [Here](https://vyxal.pythonanywhere.com/?v=2#WyIiLCIiLCJcbiMgU3ltYm9sczogXG4jIMKiwqLCosKiL8KiwqLCosKiwqLCosKiwqIvwqLCosKiwqLCosKiwqLCoi/CosKiwqLCoiA9IDFcbiMgwqLCosKiwqIvwqLCosKiwqLCosKiwqLCoi/CosKiwqLCosKiwqIvwqLCoi/CosKiICA9IDBcbiMgwqLCosKiwqIvwqLCosKiwqLCosKiL8KiwqIvwqLCosKiL8KiwqIvwqIgPSBeXG4jIMKiwqLCosKiL8KiwqLCosKiwqLCoi/CosKiL8KiwqLCosKiwqIvwqLCosKiwqIgPSAqXG4jIC8vwqLCoi8vID0gZGVsaW1cblxuIyBUaGlzIGJpdCBpcyBqdXN0IHByZXByb2Nlc3NpbmcgdGhlIGlucHV0LiBUaGUgaW5wdXQgY291bGQganVzdCBiZSBpbnNlcnRlZCBkaXJlY3RseSBpbnRvIHRoZSBwcm9ncmFtLlxuYDFgIGDCosKiwqLCoi/CosKiwqLCosKiwqLCosKiL8KiwqLCosKiwqLCosKiwqIvwqLCosKiwqJgIFZcbmAwYCBgwqLCosKiwqIvwqLCosKiwqLCosKiwqLCoi/CosKiwqLCosKiwqIvwqLCoi/CosKiYCBWXG5gXmAgYMKiwqLCosKiL8KiwqLCosKiwqLCoi/CosKiL8KiwqLCosKiL8KiwqIvwqLComAgVlxuYCpgIGDCosKiwqLCoi/CosKiwqLCosKiwqIvwqLCoi/CosKiwqLCosKiwqIvwqLCosKiwqJgIFZcblxuYElucHV0OiBgICwg4oCmXG46IMO4RCBgSW5wdXQgcmVwcmVzZW50YXRpb246IGAgLCAsXG5cbiMgSGVyZSdzIHRoZSBhY3R1YWwgcHJvZ3JhbVxuXG5gwqLCosKiwqIvwqLCosKiwqLCosKiwqLCoi/CosKiwqLCosKiwqLCosKiL8KiwqLCosKiLy/CosKiLy/CosKiwqLCoi/CosKiwqLCosKiwqIvwqLCoi/CosKiwqLCosKiwqIvwqLCosKiwqLCosKiwqLCoi/CosKiwqLCosKiwqLCosKiL8KiwqLCosKiwqLCoi/CosKiL8KiwqIvL8KiwqIvL8KiwqLCosKiL8KiwqLCosKiwqLCoi/CosKiL8KiwqLCosKiL8KiwqIvwqLCosKiwqLCosKiL8KiwqLCosKiwqLCosKiwqIvwqLCosKiwqLCosKiL8KiwqIvwqLComBgLy/CosKiLy9gL2DCosKiwqLCoi/CosKiwqLCosKiwqLCosKiL8KiwqLCosKiwqLCoi/CosKiL8KiwqLCosKiwqLCoi/CosKiwqLCosKiwqIvwqLCoi/CosKiwqLCosKiwqIvwqLCosKiwqIvL8KiwqIvL8KiwqLCosKiL8KiwqLCosKiwqLCosKiwqIvwqLCosKiwqLCosKiL8KiwqIvwqLCosKiwqLCosKiL8KiwqLCosKiwqLCoi/CosKiL8KiwqLCosKiwqLCoi/CosKiwqLCosKiwqLCosKiL8KiwqLCosKiwqLCoi/CosKiL8KiwqLCosKiwqLCoi/CosKiwqLCoi8vwqLCoi8vwqLCosKiwqIvwqLCosKiwqLCosKiL8KiwqIvwqLCosKiwqIvwqLCoi/CosKiYGAvL8KiwqIvL2AvwqJcblxuIyBwb3N0cHJvY2Vzc2luZ1xuXG5gT3V0cHV0OiBgICwg4oCmXG46IMO4RCBgT3V0cHV0IHJlcHJlc2VudGF0aW9uOiBgICwgLFxuXG5gwqLCosKiwqIvwqLCosKiwqLCosKiL8KiwqIvwqLCosKiwqLCosKiL8KiwqLCosKiYCBgKmAgVlxuYMKiwqLCosKiL8KiwqLCosKiwqLCoi/CosKiL8KiwqLCosKiL8KiwqIvwqLComAgYF5gIFZcblxuYFJlYWRhYmxlIHVuYXJ5IG91dHB1dDogYCAsIOKAplxuXG5gTnVtYmVyOmAsTOKAuSxcblxuIiwiIiwiXjEwMTEiXQ==)'s a extremely-overcomplicated binary-to-unary converter with some vague explanations of what's going on, and it's possible to expand this approach to emulate any possible Thue program.
I feel like three characters is optimal for this, and I can't imagine how a two-character solution would work.
[Answer]
# [Skull](https://esolangs.org/wiki/Skull), 9 characters
```
[]{}|:NUM
```
So Skull is an interesting language. You need `NUM` to set number mode. This adds to the amount of characters you need as you have to use one at the beginning of your programs. Also I mean that is the entire language except for 3 other characters.
`{ x [ y ] }` Increment or decrement the specified cell (x) by the specified number `(y)`
`{ x {` While the specified cell (x) is not 0...
`} }` End while
`| x |` Print out the specified cell (x) to the screen
This is a simple program doing addition (4+2)
```
:NUM:       // set mode to NUM
{0[+4]}      // set cell 0 to 4
{1[+2]}      // set cell 1 to 2
{0{         // while cell 0 is not 0
  {0[-1]}   // subtract cell 0 by 1
  {1[+1]}   // add 1 to cell 1
}}          // end while
|1|         // print cell 1 (6)
```
]


[Question]
      [
Your task is to write a program or a function that prints an ASCII triangle. They look like this:
```
|\
| \
|  \
----
```
Your program will take a single numeric input `n`, with the constraints `0 <= n <= 1000`. The above triangle had a value of `n=3`.
The ASCII triangle will have `n` backslashes (`\`) and vertical bars (`|`), `n+1` lines and dashes (`-`), and each line will have an amount of spaces equal to the line number (0-based, ie first line is line 0) besides the ultimate line.
## Examples:
Input:
```
4
```
Output:
```
|\
| \
|  \
|   \
-----
```
Input:
```
0
```
Output:
```

```
In this test case, the output must be empty. No whitespace.
Input:
```
1
```
Output:
```
|\
--
```
Input & output must be **exactly** how I specified.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so aim for the shortest code possible!

[Answer]
# C, 58 bytes
```
i;f(n){for(i=2*n;~i--;printf(i<n?"-":"|%*c\n",2*n-i,92));}
```
--
Thanks to @Steadybox who's comments on [this answer](https://codegolf.stackexchange.com/a/109512/16513) helped me shave a few bytes in my above solution
[Answer]
## Javascript (ES6), ~~97~~ ~~85~~ ~~81~~ ~~75~~ 74 bytes
```
n=>(g=(n,s)=>n?g(--n,`|${" ".repeat(n)}\\
`+s):s)(n,"")+"-".repeat(n&&n+1)
```
Turns out I wasn't using nearly enough recursion
```
f=n=>(g=(n,s)=>n?g(--n,`|${" ".repeat(n)}\\
`+s):s)(n,"")+"-".repeat(n&&n+1)
console.log(f(0))
console.log(f(1))
console.log(f(2))
console.log(f(3))
console.log(f(4))
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~16~~ ~~15~~ 16 bytes
Saved a byte thanks to *Adnan*
```
FðN×…|ÿ\}Dg'-×»?
```
[Try it online!](https://tio.run/nexus/05ab1e#ARsA5P//RsOwTsOX4oCmfMO/XH1EZyctw5fCuz///zQ "05AB1E – TIO Nexus")
**Explanation**
```
F       }         # for N in range [0 ... input-1]
 ðN×              # push <space> repeated N times
    …|ÿ\          # to the middle of the string "|\"
         Dg       # get length of last string pushed
           '-×    # repeat "-" that many times
              »   # join strings by newline
               ?  # print without newline
```
[Answer]
# [V](https://github.com/DJMcMayhem/V), ~~18~~ ~~17~~ 16 bytes
*1 byte saved thanks to @nmjcman101 for using another way of outputting nothing if the input is `0`*
```
é\é|ÀñÙá ñÒ-xÀ«D
```
[Try it online!](https://tio.run/nexus/v#@394ZczhlTWHGw5vPDzz8EIFIDVJt@Jww6HVLv///zcAAA "V – TIO Nexus")
Hexdump:
```
00000000: e95c e97c c0f1 d9e1 20f1 d22d 78c0 ab44  .\.|.... ..-x..D
```
### Explanation (outdated)
We first have a loop to check if the argument is `0`. If so, the code below executes (`|\` is written). Otherwise, nothing is written and the buffer is empty.
```
Àñ     ñ            " Argument times do:
  é\é|              " Write |\
      h             " Exit loop by creating a breaking error
```
Now that we got the top of the triangle, we need to create its body.
```
Àñ   ñ              " Argument times do:
  Ù                 " Duplicate line, the cursor comes down
   à<SPACE>         " Append a space
```
Now we got one extra line at the bottom of the buffer. This has to be replaced with `-`s.
```
Ó-                  " Replace every character with a -
   x                " Delete the extra '-'
```
---
This answer would be shorter if we could whatever we want for input `0`
# [V](https://github.com/DJMcMayhem/V), ~~14~~ 13 bytes
```
é\é|ÀñÙá ñÒ-x
```
[Try it online!](https://tio.run/nexus/v#@394ZczhlTWHGw5vPDzz8EIFIDVJt@L///8mAA "V – TIO Nexus")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
’⁶x⁾|\jṄµ€Ṫ”-ṁ
```
[Try it online!](https://tio.run/nexus/jelly#ASQA2///4oCZ4oG2eOKBvnxcauG5hMK14oKs4bmq4oCdLeG5gf///zQ "Jelly – TIO Nexus")
### How it works.
```
’⁶x⁾|\jṄµ€Ṫ”-ṁ  Main link. Argument: n
        µ       Combine the links to the left into a chain.
         €      Map the chain over [1, ..., n]; for each k:
’                 Decrement; yield k-1.
 ⁶x               Repeat the space character k-1 times, yielding a string.
   ⁾\j            Join the character array ['|', '\'], separating by those spaces.
      Ṅ           Print the result, followed by a linefeed.
         Ṫ      Tail; extract the last line.
                This will yield 0 if the array is empty.
          ⁾-ṁ   Mold the character '-' like that line (or 0), yielding a string
                of an equal amount of hyphen-minus characters.
```
[Answer]
# C#, 93 bytes
```
n=>{var s=n>0?new string('-',n+1):"";while(n-->0)s="|"+new string(' ',n)+"\\\n"+s;return s;};
```
Anonymous function which returns the ASCII triangle as a string.
Full program with ungolfed, commented function and test cases:
```
using System;
class ASCIITriangles
{
    static void Main()
    {
      Func<int, string> f =
      n =>
      {
          // creates the triangle's bottom, made of dashes
          // or an empty string if n == 0
          var s = n > 0 ? new string('-', n + 1) : "";
          // a bottom to top process
          while ( n-- > 0)
          // that creates each precedent line
            s = "|" + new string(' ', n) + "\\\n" + s;
          // and returns the resulting ASCII art
          return s;
      };
      // test cases:
      Console.WriteLine(f(4));
      Console.WriteLine(f(0));
      Console.WriteLine(f(1));
    }
}
```
[Answer]
# [Python 2](https://docs.python.org/2/), 69 bytes
```
lambda x:'\n'.join(['|'+' '*n+'\\'for n in range(x)]+['-'*-~x*(x>0)])
```
[Try it online!](https://tio.run/nexus/python2#FcpBCsIwEAXQvaeY3Z8kbangqmAvkmSRopERnZZQIQvx6pG@9cvX0F7pvdwS1QlBMTxXUfb4woFg1SEE5LWQkiiVpI87VxOdRw/b/6rlOo8mmnYcOY7o9tnZTCfaiuhOmcU0P3bn7hL/ "Python 2 – TIO Nexus")
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~24~~ ~~22~~ 21 bytes
*Saved 1 byte thanks to Martin Ender*
```
ri_{S*'|\'\N}%\_g+'-*
```
[Try it online!](https://tio.run/nexus/cjam#@1@UGV8drKVeE6Me41erGhOfrq2uq/X/vxEA "CJam – TIO Nexus")
**Explanation**
```
ri                     e# Take an integer from input
  _                    e# Duplicate it
   {                   e# Map the following to the range from 0 to input-1
    S*                 e#   Put that many spaces
      '|               e#   Put a pipe
        \              e#   Swap the spaces and the pipe
         '\            e#   Put a backslash
           N           e#   Put a newline
            }%         e# (end of map block)
              \        e# Swap the top two stack elements (bring input to the top)
               _g+     e# Add the input's signum to itself. Effectively this increments any
                       e#  non-zero number and leaves zero as zero.
                  '-*  e# Put that many dashes
```
[Answer]
# [PowerShell](https://github.com/PowerShell/PowerShell), ~~51~~ 67 bytes
```
param($n)if($n){1..$n|%{"|"+" "*--$_+"\"};write-host -n ('-'*++$n)}
```
[Try it online!](https://tio.run/nexus/powershell#@1@QWJSYq6GSp5mZBiKrDfX0VPJqVKuVapS0lRSUtHR1VeK1lWKUaq3LizJLUnUz8otLFHTzFDTUddW1tLWBWmr///9vAgA "PowerShell – TIO Nexus")
*(Byte increase to account for no trailing newline)*
Takes input `$n` and verifies it is non-zero. Then loops to construct the triangle, and finishes with a line of `-`. Implicit `Write-Output` happens at program completion.
[Answer]
# bash + printf, 68 bytes
```
for((;i<$1;))
{
a=$a-
printf "|%$[i++]s\\\\\n"
}
[ $a ] && echo $a-
```
Use "bash *program\_name* *number*" to run. Sample run:
```
bash-4.1$ bash triangle 0
bash-4.1$ bash triangle 1
|\
--
bash-4.1$ bash triangle 2
|\
| \
---
bash-4.1$ bash triangle 3
|\
| \
|  \
----
```
[Answer]
# SmileBASIC, 51 bytes
```
INPUT N
FOR I=0TO N-1?"|";" "*I;"\
NEXT?"-"*(N+!!N)
```
[Answer]
# [Retina](https://github.com/m-ender/retina), 39 bytes
```
.*
$*
*\`(?<=(.*)).
|$.1$* \¶
1
-
-$
--
```
[**Try it online**](https://tio.run/nexus/retina#@6@nxaWixaUVk6Bhb2OroaelqanHVaOiZ6iipRBzaBuXIZcul64Kl67u///GAA)
Convert decimal input to unary. Replace each `1` with `|<N-1 spaces>\¶`, print, and undo replace. Replace each `1` with a hyphen, and the last hyphen with 2 hyphens. Tadaa!
[Answer]
# Common Lisp, ~~89~~ 86 bytes
Creates an anonymous function that takes the n input and prints the triangle to `*standard-output*` (stdout, by default).
## Golfed
```
(lambda(n)(when(< 0 n)(dotimes(i n)(format t"|~v@t\\~%"i))(format t"~v,,,'-<~>"(1+ n))))
```
## Ungolfed
```
(lambda (n)
  (when (< 0 n)
    (dotimes (i n)
      (format t "|~v@t\\~%" i))
    (format t "~v,,,'-<~>" (1+ n))))
```
I'm sure I could make this shorter somehow.
[Answer]
## C ~~101~~ ~~93~~ 75 bytes
```
f(n){i;for(i=0;i++<n;)printf("|%*c\n",i,92);for(;n--+1;)printf("-");}
```
Ungolfed version
```
void f(int n)
{
  int i;
  for(i=0;i++<n;)
    printf("|%*c\n",i,92);
  for(;n--+1;)
    printf("-");
}
```
@Steadybox Thanks for pointing out, makes a lot of sense.
[Answer]
# [Python 3](https://docs.python.org/3/), 60 bytes
```
f=lambda n,k=0:k<n and'|'+' '*k+'\\\n'+f(n,k+1)or'-'[:n]*-~n
```
[Try it online!](https://tio.run/nexus/python3#@59mm5OYm5SSqJCnk21rYJVtk6eQmJeiXqOura6grpWtrR4TE5Onrp2mAZTXNtTML1LXVY@2yovV0q3L@19QlJlXopGmYaKp@R8A "Python 3 – TIO Nexus")
Two more solutions with the same byte count.
```
f=lambda n,k=0:n and'|'+' '*k+'\\\n'+f(n-1,k+1)or-~k*'-'[:k]
f=lambda n,s='|':-~n*'-'[:n]if s[n:]else s+'\\\n'+f(n,s+' ')
```
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), 98 bytes
```
256?dse1+d[q]st1=t^124*23562+dsaP2sk[[lkd256r^32*la+dsaPd1+skle>y]srle1<r]dsyx[45Ple1-dse0!>q]dsqx
```
[Try it online!](https://tio.run/nexus/dc#HYzLCoAgEAC/pWsStFt26vEL3sVAWiFQCt0O9eGdTTrOMExGOSzEDgTpaPiC6VoB@xo7OaAgtgrZax08lTCtHdbB/ppAsA9ufgyn4GBMhvi5dS9VoaYc22qOxcU7Z/keZ7PZbXcf "dc – TIO Nexus")
### Explanation
This takes due advantage of dc's `P` command, which utilizes conversion to base `256` on most systems. Therefore, for any input `n`, the program first raises `256` to the `n + 1`th power, multiplies the result by `124` (ASCII character `|`), and then adds `256*92+10=23562` to the product (where `92` is equivalent to the character `\` and `10` is the decimal value of the new-line (`\n`)). This results in a decimal number that when converted to base `256` with `P` results in the output `|\\n` where `\n` is the literal new-line character. A duplicate of this decimal number is also stored on top of register `a`.
Then, a "macro-loop" is invoked, as long as `n > 1`, in which a counter is incremented until `n`, beginning from `2`, and, as the 3rd through `n`th base `256` digits are unset, `256` is raised to each of those increments, a result which is then multiplied by `32` (the ASCII single space character). Then the value on top of register `a` is incremented by the resulting product, thus, on each iteration, setting each one of the unset base `256` digits in the between the `|` and the `\` characters to a single space.
Finally, after all `n-1` lines have been output, another "macro-loop" is invoked in which all the `n+1` dashes are output through the feeding of `45` to `P` on each iteration.
*Note:* The `[q]st1=t` segment makes sure that nothing is output for the input `0` by checking if the incremented input is equal to one, and if it is, simply executes the macro `[q]` which exits the program.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 15 bytes
```
Ｎβ¿β«↓β→⁺¹β↖↖β»
```
[Try it online!](https://tio.run/nexus/charcoal#@/9@z7pzmw7tB@LVj9omn9v0qG3So8Zdh3aCWNOACCix@/9/AwA "Charcoal – TIO Nexus")
## Breakdown
```
Ｎβ¿β«↓β→⁺¹β↖↖β»
Ｎβ               assign input to variable β
   ¿β«         »  if β != 0:
      ↓β           draw vertical line β bars long
        →⁺¹β       draw horizontal line β+1 dashes long
            ↖      move cursor up one line and left one character
             ↖β    draw diagonal line β slashes long
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 20 bytes
Saved 2 bytes thanks to @ETHproductions
```
o@'|+SpX +'\Ãp-pUÄ)·
```
[Try it online!](https://tio.run/nexus/japt#@5/voF6jHVwQoaCtHnO4@dB27SBtdd2C0MMt//@bAAA "Japt – TIO Nexus")
### Explanation
```
o@'|+SpX +'\Ãp-pUÄ)·
o                       // Creates a range from 0 to input
 @                      // Iterate through the array
  '|+                   // "|" +
     SpX +              // S (" ") repeated X (index) times +
          '\Ã            // "\" }
             p-pU       // "-" repeated U (input) +1 times
                 Ä)·    // Join with newlines
```
[Answer]
# J, 20 bytes
*-13 bytes thanks to bob*
```
*#' \|-'{~3,~2,.=@i.
```
[Try it online!](https://tio.run/##y/qfVqxga6VgoADE/7WU1RVianTVq@uMdeqMdPRsHTL1/mtyKekpqKfZWqkr6CjUWimkFXNxpSZn5CukKRjCGKb/AQ "J – Try It Online")
## original: 33 bytes
```
(#&'| \'@(1,1,~])"0 i.),('-'#~>:)
```
### ungolfed
```
(#&'| \' @ (1,1,~])"0 i.) , ('-'#~>:)
```
[Try it online!](https://tio.run/##y/r/P81WT0FDWU29RiFG3UHDUMdQpy5WU8lAIVNPU0dDXVdduc7OSpMrNTkjXyFNweT/fwA "J – Try It Online")
[Answer]
# Commodore BASIC (C64/128, TheC64 & Mini, VIC-20, PET, C16/+4) - 46 BASIC Bytes
```
0inputn:ifnthenfori=1ton:?"{shift+B}{left}"spc(i)"{shift+M}":next:fori=.ton:print"-";:next
```
There is a sanity check for zero, but any other positive integer will work.
Note, a C64 has 25 rows and 40 columns text (some PETs and the C128 in VDC mode has 80 columns, the VIC-20 is 22 columns by 23 rows) so the output will be skewed if you exceed the screen limit in either direction.
I've added a screenshot so that you may see the PETSCII characters that I can't make happen in this listing.
[![Commodore C64 Triangle challenge](https://i.stack.imgur.com/eqgz8.png)](https://i.stack.imgur.com/eqgz8.png)
[Answer]
## Pyke, ~~18~~ 17 bytes
```
I Fd*\|R\\s)Qh\-*
```
[Try it here!](http://pyke.catbus.co.uk/?code=I+Fd%2a%5C%7CR%5C%5Cs%29Qh%5C-%2a&input=4)
[Answer]
# Python2, 73 bytes
```
n=input()
w=0
exec'print"|"+" "*w+"\\\\"+("\\n"+"-"*-~n)*(w>n-2);w+=1;'*n
```
A full program. I also tried string interpolation for the last line, but it turned out be a couple bytes longer :/
```
exec'print"|%s\\\\%s"%(" "*w,("\\n"+"-"*-~n)*(w>n-2));w+=1;'*n
```
Another solution at 73 bytes:
```
n=j=input()
exec'print"|"+" "*(n-j)+"\\\\"+("\\n"+"-"*-~n)*(j<2);j-=1;'*n
```
# Test cases
```
0:
1:
|\
--
2:
|\
| \
---
3:
|\
| \
|  \
----
6:
|\
| \
|  \
|   \
|    \
|     \
-------
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 19 bytes
```
?'\|- '2GXyYc!3Yc!)
```
[Try it online!](https://tio.run/nexus/matl#@2@vHlOjq6Bu5B5RGZmsaAzEmv//GwMA "MATL – TIO Nexus")
```
?         % Implicit input. If non-zero
  '\|- '  %   Push this string
  2       %   Push 2
  G       %   Push input
  Xy      %   Identity matrix of that size
  Yc      %   Prepend a column of 2's to that matrix
  !       %   Transpose
  3       %   Push 3
  Yc      %   Postpend a column of 3's to the matrix
  !       %   Transpose
  )       %   Index into string
          % Implicit end. Implicit display
```
[Answer]
## [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 41 bytes
```
:~a>0|[a|?@|`+space$(b-1)+@\`][a+1|Z=Z+@-
```
Explanation
```
:~a>0|  Gets a, and checks if a > 0
        If it isn't the program quits without printing anything
[a|     For b=1; b <= a; b++
?@|`+   Print "|"
space$  and a number of spaces
(b-1)   euqal to our current 1-based line - 1
+@\`    and a "\"
]       NEXT
[a+1|   FOR c=1; c <= a+1; c++
Z=Z+@-  Add a dash to Z$
        Z$ gets printed implicitly at the end of the program, if it holds anything
        The last string literal, IF and second FOR loop are closed implicitly.
```
[Answer]
## R, 101 bytes
```
for(i in 1:(n=scan())){stopifnot(n>0);cat("|",rep(" ",i-1),"\\\n",sep="")};cat("-",rep("-",n),sep="")
```
This code complies with the `n=0` test-case if you only consider `STDOUT` !
Indeed, the `stopifnot(n>0)` part stops the script execution, displays nothing to `STDOUT` but writes `Error: n > 0 is not TRUE` to `SDTERR`.
**Ungolfed :**
```
for(i in 1:(n=scan()))
    {
    stopifnot(n>0)
    cat("|", rep(" ", i-1), "\\\n", sep = "")
    }
cat("-", rep("-", n), sep = "")
```
[Answer]
# [Python 2](https://docs.python.org/2/), 62 bytes
```
n=input();s='\\'
exec"print'|'+s;s=' '+s;"*n
if n:print'-'*-~n
```
[Try it online!](https://tio.run/nexus/python2#@59nm5lXUFqioWldbKseE6POlVqRmqxUUJSZV6Jeo65dDBJWANFKWnlcmWkKeVYQOV11Ld26vP//TQA "Python 2 – TIO Nexus")
Prints line by line, each time adding another space before the backslash. If a function that doesn't print would be allowed, that would likely be shorter.
[Answer]
## JavaScript (ES6), 71 bytes
```
f=
n=>console.log(' '.repeat(n).replace(/./g,'|$`\\\n')+'-'.repeat(n+!!n))
```
```
<form onsubmit=f(+i.value);return!true><input id=i type=number><input type=submit value=Go!>
```
Outputs to the console. Save 6 bytes if printing to the SpiderMonkey JavaScript shell is acceptable. Save 13 bytes if returning the output is acceptable.
[Answer]
# Befunge-98, 68 bytes
```
&:!#@_000pv<
:kg00 ',|'<|`g00:p00+1g00,a,\'$,kg00
00:k+1g00-'<@,k+1g
```
[Answer]
# [Python 2](https://docs.python.org/2/), 67 bytes
Another function in Python 2, using `rjust`.
```
lambda n:('|'.join(map('\\\n'.rjust,range(n+2)))+'-'*-~n)[4:]*(n>0)
```
[Try it online!](https://tio.run/nexus/python2#DcIxDoMwDADAva/wZhsCohVTJPgIYQiiqYyKiULYqn497enC4Mrb78vqQS3hB9vtEKXdR0LnnGKbtuvMJnl9PUnrBzPX2GDVfJWn3s4V6dhxCUcCAdH/eGVie4OYRDMEEi5TZ@6mn38 "Python 2 – TIO Nexus")
[Answer]
# Perl, 63 bytes
```
$n=shift;print'|',$"x--$_,"\\\n"for 1..$n;print'-'x++$n,$/if$n
```
Ungolfed:
```
$ perl -MO=Deparse triangle.pl
$n = shift @ARGV;
print '|', $" x --$_, "\\\n" foreach (1 .. $n);
print '-' x ++$n, $/ if $n;
```
`$"` is the list separator, which defaults to " ". `$/` is the output record separator, which defaults to "\n". `$_` is the implicit loop variable.
]


[Question]
      [
Long-time lurker, first-time poster. So here goes.
In the Wikipedia page for [quine](https://en.wikipedia.org/wiki/Quine_%28computing%29#.22Cheating.22_quines), it says that "a quine is considered to be 'cheating' if it looks at its own source code." Your task is to make one of these "cheating quines" that reads its own source code.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes - *in each language* - wins. This means that a 5-byte Pyth script would not beat a 21-byte Python script - but a 15-byte Python script would.
You must use file I/O to read the source code, so the following JavaScript code, taken from the official Wikipedia page, is invalid:
```
function a() {
    document.write(a, "a()");
}
a()
```
It must access the source code of the file *on disk*.
**You are not allowed to specify the file name. You must make it detect the filename itself.**
Everyone clear? Go!

[Answer]
# [PARI/GP](https://pari.math.u-bordeaux.fr), 18 bytes
```
print1(readstr[1])
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728ILEoMz69YMGCpaUlaboWmwqKMvNKDDWKUhNTikuKog1jNSESUHmYOgA)
The function `readstr` reads every lines as strings form a file. When `readstr` takes no input, it reads the source file.
[Answer]
# [C (clang)](http://clang.llvm.org/), 47 (46?) bytes
```
main(s){write(!!read(open(__FILE__,0),&s,47));}
```
[Try it online!](https://tio.run/##S9ZNzknMS///PzcxM0@jWLO6vCizJFVDUbEoNTFFI78gNU8jPt7N08c1Pl7HQFNHrVjHxFxT07r2/38A "C (clang) – Try It Online")
This **will** corrupt the stack and segfault, but not before printing the correct output.
If executing in a terminal we can do 46 bytes printing to `stdin`:
```
main(s){write(!read(open(__FILE__,0),&s,46));}
```
[Answer]
# Bash, 18 Bytes
```
history|tail -c18
```
**Note:** *Technically* this is not allowed because it gets history from memory, and not from disk.
##  Bytes:
```
echo 'history|tail -c18' > quine
wc -c quine
18 quine
```
18 bytes (including the newline)
## Explanation:
`history` gets the bash history from memory and `tail` grabs the last 18 characters. This is a more proper quine than `cat $0` and `#!/bin/cat` because it includes the newline.
`echo "$BASH_COMMAND"` can be used to do the same thing for an extra 1 character.
[Answer]
## Tcl, 37 bytes
```
chan copy [open [info script]] stdout
```
The older, more self explanatory version (43 bytes):
```
puts -nonewline [read [open [info script]]]
```
[Answer]
# Lua, 59 characters
```
print(io.open(debug.getinfo(1,'S').source:sub(2)):read'*a')
```
Sample run:
```
bash-4.3$ lua quine.lua
print(io.open(debug.getinfo(1,'S').source:sub(2)):read'*a')
```
[Answer]
# C++, 93 bytes
```
#include <iostream>
#include <fstream>
main(){std::fstream f(__FILE__);std::cout<<f.rdbuf();}
```
I wanted to do a “pure” C++ version…and I have to say that it doesn't do too badly: it's down to 54 bytes if I can do without including the headers.
[Answer]
# A Groovy ~~103~~ 100 bytes!
Yes I know I'm evil
I stay in line with the other JVM answers (Java, Scala) to make this answer.
```
class X{static def main(String[]a){new X()}
def X(){print new File(getClass().name+'.groovy').text}}
```
[Answer]
# Emacs Lisp (93 Bytes)
```
:; emacs -Q -script $0; exit
(find-file (nth 2 command-line-args))
(message (buffer-string))
```
The first line calls the program in your normal shell and exits (to prevent the rest also being evaluated). `command-line-args` will be a list of three strings, `"emacs"`, `"-scriptload"` and the name of your file. `find-file` will open that file and make it the current buffer, so that `(message (buffer-string))` will write it to `stdout` as `-script` redirects messages there.
It should be noted, that `-Q` may not be necessary if your Emacs doesn't print other messages during startup, so that the first line could be shortened to `#!emacs -script`, shortening this to 81 bytes, but as it is highly unlikely that init and site-lisp files produce 0 messages at all, this cannot be assumed.
[Answer]
# Matlab, 32 bytes
```
disp(fileread([mfilename,'.m']))
```
[Answer]
# [APL](http://goo.gl/9KrKoM), 8 bytes (non-competing)
APL does not use source files for single functions, rather a whole workspace (a machine-readable collection of token-representations) is saved and loaded, so I guess this is not allowed:
```
f
⎕CR'f'
```
(`⎕CR` is Character Representation) as the program reads its current definition in memory (the loaded workspace), which may have been modified from the source in the file.
[Answer]
# HTML and Javascript, 88 Bytes
```
<head></head><body><svg onload="alert(document.documentElement.innerHTML)"></svg></body>
```
Had to add `<head></head><body></svg></body>` because that's what the browser outputs regardless of the original file.
[Answer]
# [Lua](https://www.lua.org), ~~32~~ 29 bytes
*3 bytes saved thanks to Jonathan Frech*
```
print(io.open(arg[0]):read())
```
### [Try it online!](https://tio.run/##yylN/P@/oCgzr0QjM18vvyA1TyOxKD3aIFbTqig1MUVDU/P/fwA "Lua – Try It Online")
## How?
Lua uses the `arg` table to store it's arguments, the script name is always stored at index `0` of this table despite the fact there are no further arguments. After using this table to get the name of the file, printing it was as easy as opening the file and reading its content.
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg) / POSIX shell, 16 bytes
```
run 'cat',$?FILE
```
[Try it online!](https://tio.run/##K0gtyjH7/7@oNE9BPTmxRF1Hxd7N08f1/38A "Perl 6 – Try It Online")
[Answer]
## [CopyPasta Language](https://esolangs.org/wiki/CopyPasta_Language), 32 bytes
But I think this is interesting enough to compete here.
```
CopyFile
TheFuckingCode
Pasta!
```
Copy the source code, display the clipboard, and stop the program.
[Answer]
# [stacked](https://github.com/ConorOBrien-Foxx/stacked), 11 bytes
```
program put
```
[Try it here!](https://conorobrien-foxx.github.io/stacked/stacked.html)
Outputs the program stored in the `program` variable. Simple!
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly) `u`, 26 bytes
```
“open(sys.argv[2])”ŒV
```
[Try it online!](https://tio.run/##y0rNyan8//9Rw5z8gtQ8jeLKYr3EovSyaKNYzUcNc49OCvv/HwA "Jelly – Try It Online")
*Not* encoded in Jelly's SBCS, because 1. by meta consensus on flags Jelly `u` is a different language from Jelly (so it's not like I'm handicapping myself or anything), 2. I'm having some difficulties deciding on what form of output would be valid for an SBCS Jelly cheating quine, and 3. I'm having some difficulties [actually executing on the methods I've considered](https://tio.run/##S0oszvj/v6CyJCM/z1jBxkbB1d@NK60oP1chKzUnp1IhM7cgv6hEITk/JTW@IDE9laugKD@9KDFXwVZB/VHDnBPbrY9MP7b0UeP2h7u7c80Ob4g/PP/Q5sMTVA8ve7iz7cT6wxOP7Nc5tPvopDCg/OEZXupc5ZklGQr5Bal5GupQo@LTMnNS1XXUy5PUNRUSixXSrLgU0vTKizJLUjWSKktSizXgtutl5qWkVmgkayqk5RcpJCtk5inA3JOZBuHD1WpqcoH8kpxYooBsEVdqckY@F8RzaSgy//8DAA) (note that that's not even shorter than this).
```
“open(sys.argv[2])”ŒV    Evaluate "open(sys.argv[2])" as Python, within Jelly's interpreter.py.
      sys.argv           Get the arguments with which this was invoked on the command line.
                         (jelly fu [whatever the file's called])
              [2]        Take the third argument,
 open(           )       and open the file at that location.
                   ŒV    Iterate through the file object, obtaining a Jelly string of its contents.
```
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), ~~43~~ ~~39~~ ~~30~~ 27 bytes
```
’ƒÛ(__£Ø__('Ë‚').Òœv[1])’.E
```
[Try it online!](https://tio.run/##MzBNTDJM/f//UcPMY5MOz9aIjz@0@PCM@HgN9cPdjxpmqWvqHZ50dHJZtGGsJlCJnuv//wA "05AB1E (legacy) – Try It Online") I would've used the rewrite, if only I knew Elixir… Output doesn't contain the program, however it is the program in a singleton iterable object (a file). [This is allowed](https://codegolf.meta.stackexchange.com/a/11884/94066).
```
’ƒÛ(__£Ø__('Ë‚').Òœv[1])’.E  # full program
’ƒÛ(__£Ø__('Ë‚').Òœv[1])’    # push "open(__import__('sys').argv[1])"...
                         .E  # evaluated as Python code
                             # implicit output
============================================================================
open(__import__('sys').argv[1])  # full Python program
open(                         )  # return file at path...
                           [1]   # second...
     __import__('sys').argv      # command-line argument
```
**Note:** This program assumes no command-line flags or extra arguments are passed. If this assumption is not allowed, it can be fixed at a cost of 1 byte by adding a `-` before the `1`.
[Answer]
# [Julia 1.0](http://julialang.org/), ~~29~~ 26 bytes
```
print(readline(@__FILE__))
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/v6AoM69Eoyg1MSUnMy9VwyE@3s3TxzU@XlPz/38A "Julia 1.0 – Try It Online")
[Answer]
# Processing, 48 bytes
```
print(loadStrings(getClass().getName()+".pde"));
```
[Answer]
# Nim, 43 bytes
```
import os
echo readFile(paramStr(0)&".nim")
```
[Answer]
# JavaScript ([Deno](https://deno.dev/)), ~~49~~ 47 bytes
```
console.log(Deno.readFileSync(import.meta.url))
```
[Answer]
# C, 31 bytes
```
main(){system("cat "__FILE__);}
```
Works perfectly...
[Answer]
# [Nim](https://nim-lang.org/), 39 bytes
```
stdout.write currentSourcePath.readFile
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m704LzN3wYKlpSVpuhY31YtLUvJLS_TKizJLUhWSS4uKUvNKgvNLi5JTAxJLMvSKUhNT3DJzUiHKobpgugE)
]