[Question]
  [
It's a [normal truth machine](https://esolangs.org/wiki/Truth-machine) but instead of taking input, it uses the first character of the program. Thus, internal.
The 0 and 1 are plain characters, i.e. ASCII code 0x30 and 0x31 respectively.
Example: `0abcd` prints 0 and halts, and `1abcd` prints 1 infinitely. Then your submission is `abcd`, whose score is 4 bytes. The 0 or 1 (the first character of the program) is not counted towards your score.
Of course, you're not allowed to look inside the file itself. Like a quine.
## Leaderboard
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
```
/* Configuration */
var QUESTION_ID = 198288; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.
/* App */
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}
function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}
function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}
function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) {
  return a.owner.display_name;
}
function process() {
  var valid = [];
  
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });
  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);
    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();
    
    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });
  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);
  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });
  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }
}
```
```
body { text-align: left !important}
#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}
#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}
table thead {
  font-weight: bold;
}
table td {
  padding: 5px;
}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">
    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">
    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
```
  
[Answer]
# [Python 3](https://docs.python.org/3/), 29 bytes
```
 or~print(0)
while 1:print(1)
```
A full program, which if prefixed with `0` will print `0` then halt, exiting with an error, or if prefixed with `1` will print `1` forever.
**[Try 0 online!](https://tio.run/##K6gsycjPM/7/30Ahv6iuoCgzr0TDQJOrPCMzJ1XB0AoiYKgJlE/MS9GosLI11MwvUkBTVwFVV6EJAA "Python 3 – Try It Online")**  
**[Try 1 online!](https://tio.run/##K6gsycjPM/7/31Ahv6iuoCgzr0TDQJOrPCMzJ1XB0AoiYKj5/79BYl6KRoWVraFmfpECmroKqLoKTQA "Python 3 – Try It Online")**
The right of a logical `or` is only executed if the left is falsey (which `0` is, while `1` is not).
If the prefix is `0` the argument, `print(0)`, of bitwise-not, `~`, is evaluated - this has a side-effect of printing `0` and returns `None` which is an invalid argument for `~` causing an error which halts the program.
If the prefix is `1` the code `~print(0)` is not evaluated and the infinite loop of `while 1:print(1)` is reached.
[Answer]
## [W](https://github.com/a-ee/w), 2 bytes
You know, duplicate the first character and apply while. Simple enough.
```
:w
```
## Explanation, applied the bits
```
1:  % The condition and the body is both 1
  w % While the condition 1 is true, output 1
```
## Explanation 2
```
0:  % The condition and the body is both 0
  w % This while does not get executed
    % The condition 0 gets returned & printed
```
[Answer]
# [R](https://www.r-project.org/), 20 bytes
```
->a
while(print(a))0
```
[0Try it online!](https://tio.run/##K/r/30DXLpGrPCMzJ1WjoCgzr0QjUVPT4P9/AA "R – Try It Online")
[1Try it online!](https://tio.run/##K/r/31DXLpGrPCMzJ1WjoCgzr0QjUVPT4P9/AA "R – Try It Online")
Uses rightwards assignment `->`, which I now seem to use about [once](https://codegolf.stackexchange.com/a/191416/86301) [a](https://codegolf.stackexchange.com/a/196869/86301) [month](https://codegolf.stackexchange.com/a/197103/86301) on this site (and never anywhere else).
[Answer]
# x86-16 machine code, IBM PC DOS, 11 bytes
**Binary:**
(`0` example)
```
00000000: 3002 ad8a d03c 30cd 2175 fcc3            0....<0.!u..
```
(`1` example)
```
00000000: 3102 ad8a d03c 30cd 2175 fcc3            1....<0.!u..
```
**Unassembled listing:**
```
?? 02       DB  ?, 2        ; first byte is '1' or '0', second byte is DOS write char fnc
AD          LODSW           ; load input from [SI] into AL, INT 21H function 2 in AH
8A D0       MOV  DL, AL     ; output to DL
3C 30       CMP  AL, '0'    ; is input 0?
        OUTPUT: 
CD 21       INT  21H        ; write to console
75 FC       JNZ  OUTPUT     ; if not a '0', keep looping forever
C3          RET             ; return to DOS (only if it was a 0)
```
**Explanation:**
The first byte of the program is either a `'0'` or a `'1'`, and combined with a second byte of `2` (more on that later) decodes to a benign instruction of either `XOR [BP+SI], AL` or `XOR [BP+SI], AX`. In PC DOS, many registers are [initialized to known values](http://www.fysnet.net/yourhelp.htm), so we know that `AX` is `0`, and `SI` is `100H` which is the first byte of the program. Whatever memory address `[BP+SI]` translates to, it simply XOR's `0` to it, doing nothing.
The `LODSW` instruction puts the input byte into the `AL` register and a `2` into the AH register, which is the DOS `INT 21H` API function number to write an ASCII char in `DL` to the console.
The input is compared and `ZF` (zero flag) is set "true" if input is a `0`. The char is written to the console and if `ZF` is not zero, it will loop indefinitely.
**Output of both variants:**
[![enter image description here](https://i.stack.imgur.com/mp3w6.png)](https://i.stack.imgur.com/mp3w6.png)
[Answer]
# [Haskell](https://www.haskell.org/), 32 bytes
```
!f=f 0
_!f=f 1*>0!f
main=0!print
```
I think this is the only answer posted so far where the first character (the digit) isn't the entry point.
Anyway, explanation: I'm creating an operator function called `!`, and defining it by cases. We enter the top case if the left operand matches the program's first digit, and the bottom case otherwise. The right operand is bound to `f` in both cases (and it happens to always be `print`). In the top case, we just print a 0. In the bottom case, we print a 1, and then recursively call ourself with the same operands. (We know the left operand will always be 0.) Finally, `main`, the entry point, calls our operator with `0` and `print`.
[Try it online with 0!](https://tio.run/##y0gszk7Nyfn/30AxzTZNwYArHkwbatkBBbhyEzPzbA0UC4oy80r@/wcA "Haskell – Try It Online")
[Try it online with 1!](https://tio.run/##y0gszk7Nyfn/31AxzTZNwYArHkwbatkZKKZx5SZm5tkaKBYUZeaV/P8PAA "Haskell – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes
```
µ=0
```
[Try `0µ=0` online!](https://tio.run/##yy9OTMpM/f/f4NBWW4P//wE "05AB1E – Try It Online")
[Try `1µ=0` online!](https://tio.run/##yy9OTMpM/f/f8NBWW4P//wE)
Also 3 bytes:
```
i[,
```
[Try `0i[,` online!](https://tio.run/##yy9OTMpM/f/fIDNa5/9/AA "05AB1E – Try It Online")
[Try `1i[,` online!](https://tio.run/##yy9OTMpM/f/fMDNa5/9/AA "05AB1E – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
Ṅḷ¿
```
**[Try 0 online!](https://tio.run/##y0rNyan8/9/g4c6Whzu2H9r//z8A "Jelly – Try It Online")**  
**[Try 1 online!](https://tio.run/##y0rNyan8/9/w4c6Whzu2H9r//z8A "Jelly – Try It Online")**
```
 Ṅḷ¿ - Main Link: no arguments
.    - set Left to 0 or 1
   ¿ - while...
  ḷ  - ...condition: Left
 Ṅ   - ...do: print and yield (Left)
     - implicit print (Left)
```
[Answer]
# Scratch 3.0, 10 blocks/80 bytes
[![Program](https://i.stack.imgur.com/NkFDV.png)](https://i.stack.imgur.com/NkFDV.png)
As SB Syntax:
```
//1 or 0
repeat until<(n)=[0
say[1
end
say[0
define 0
set [n v]to[0
define 1
set[n v]to[1
```
It's more of a snippet than a program, but it works.
[Try it on~~line~~ Scratch!](https://scratch.mit.edu/projects/361363482/)
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~6~~ 5 bytes
-1 thanks to Jo King!
```
:n?!;
```
**[Try 0 online!](https://tio.run/##S8sszvj/38Aqz17R@v9/AA "><> – Try It Online")**  
**[Try 1 online!](https://tio.run/##S8sszvj/39Aqz17R@v9/AA "><> – Try It Online")**
### How?
Instruction pointer starts at the top left (i.e. 0 or 1) facing right. If the instruction pointer leaves the code it wraps around to the other side, continuing in the same direction.
```
X:n?!; -               X=0                X=1
X      - push X          {0}                {1}
 :     - duplicate       {0,0}              {1,1}
  n    - pop & print     {0,} "0"           {1} "1"
   ?   - pop & if...     {}                 {}
    !  - ...truthy:      skip & wrap to X
     ; - ...falsey:                         exit
```
[Answer]
# [Labyrinth](https://github.com/m-ender/labyrinth), 5 bytes
```
"
!"@
```
**[Try 0 online!](https://tio.run/##y0lMqizKzCvJ@P/fQIlLUcnh/38A "Labyrinth – Try It Online")**  
**[Try 1 online!](https://tio.run/##y0lMqizKzCvJ@P/fUIlLUcnh/38A "Labyrinth – Try It Online")**
### How?
Instruction pointer starts at the top left (i.e. `0` or `1`) facing right, the stack starts as infinite zeros.
**0:**
```
0"
!"@
```
```
  - stack = {0,0,0,...} (infinite supply of zeros)
0 - multiply top of stack by 10 and add 0 {0,0,0,...}
  - 2 neighbours, 0 -> go forward
" - no-op {0,0,0,...}
  - 2 neighbours -> go forward
" - no-op {0,0,0,...}
  - 3 neighbours T-junction from stem, 0 -> turn around
" - no-op {0,0,0,...}
  - 2 neighbours -> go forward
0 - multiply top of stack by 10 and add 0 {0,0,0,...}
  - 2 neighbours -> go forward
! - pop top of stack, print as decimal "0" {0,0,0,...}
  - 2 neighbours -> go forward
" - no-op {0,0,0,...}
  - 3 neighbours T-junction from side, 0 -> go forward
@ - exit labyrinth
```
**1:**
```
1"
!"@
```
```
  - stack = {0,0,0,...} (infinite supply of zeros)
1 - multiply top of stack by 10 and add 1 {1,0,0,...}
  - 2 neighbours -> go forward
" - no-op {1,0,0,...}
  - 2 neighbours -> go forward
" - no-op {1,0,0,...}
  - 3 neighbours T-junction from stem, 1 -> turn right
! - pop top of stack, print as decimal "1" {0,0,0,...}
  - 2 neighbours -> go forward
1 - multiply top of stack by 10 and add 1 {1,0,0,...}
  - ...etc.
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 65 63 56 bytes
Pyth's prefix operators don't really suit well to this challenge...
```
Ws@`$__import__("inspect").stack()[1][0].f_locals$_101
1
```
Edit 1: Saved 2 bytes by letting Pyth do the dictionary index, and using `h` instead of `@<py_code>0` because I remembered it exists.
Edit 2: Saved 7 bytes because @isaacg found an even sillier trick :)
[Try it online!](https://tio.run/##K6gsyfj/3yC82CFBJT4@M7cgv6gkPl5DKTOvuCA1uURJU6@4JDE5W0Mz2jA22iBWLy0@Jz85MadYJd7QwJDL8P9/AA "Pyth – Try It Online")
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~12~~ 10 bytes
```
:?vn;
 n:<
```
-2 bytes thanks to @JonathanAllan
## Answer History
```
 :?vn;
>:n:<
```
[Try it online!](https://tio.run/##S8sszvj/X8HKvizPmsvOKs/K5v9/AA "><> – Try It Online")
or
[Try it with `1`](https://tio.run/##S8sszvj/31DByr4sz5rLzirPyub/fwA "><> – Try It Online")
[Try it with `0`](https://tio.run/##S8sszvj/30DByr4sz5rLzirPyub/fwA "><> – Try It Online")
## Explained
[![Gif showing execution path with 0](https://i.stack.imgur.com/vdAqX.gif)](https://i.stack.imgur.com/vdAqX.gif)
[![Gif showing execution path with 0](https://i.stack.imgur.com/RD6tz.gif)](https://i.stack.imgur.com/RD6tz.gif)
Path visualiser is <https://fishlanguage.com/>
Gif converter is <https://www.onlineconverter.com/video-to-gif>
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 8 bytesSBCS
```
{⍞←⍺}⍣≠1
```
[0Try it online!](https://tio.run/##SyzI0U2pTMzJT///36D6Ue@8R20THvXuqn3Uu/hR5wLD//8B "APL (Dyalog Unicode) – Try It Online")
[1Try it online!](https://tio.run/##SyzI0U2pTMzJT///37D6Ue@8R20THvXuqn3Uu/hR5wLD//8B)
Prints to stderr.
### How they work
```
0{⍞←⍺}⍣≠1
 {⍞←⍺}⍣≠   ⍝ Iterate {⍞←⍺} until (next value)≠(prev value) is true
 {⍞←⍺}     ⍝ First iteration: print and return left arg (0)
       ≠   ⍝ (next value)=0, (prev value)=1, so 0≠1 is true
           ⍝ Function terminates
1{⍞←⍺}⍣≠1
 {⍞←⍺}⍣≠   ⍝ Iterate {⍞←⍺} until (next value)≠(prev value) is true
 {⍞←⍺}     ⍝ First iteration: print and return left arg (1)
       ≠   ⍝ (next value)=1, (prev value)=1, so 1≠1 is false
 {⍞←⍺}     ⍝ Second and subsequent iterations: called with the same arg (1)
           ⍝ Never terminates; prints 1 infinitely
```
[Answer]
## [Befunge-93](https://github.com/catseye/Befunge-93), 5 bytes
```
:_.@#
```
[Try 0 online](https://tio.run/##S0pNK81LT/3/38AqXs9B@f9/AA)
[Try 1 online](https://tio.run/##S0pNK81LT/3/39AqXs9B@f9/AA)
First submission, and I only started learning Funge yesterday, so it's very likely there's a shorter solution.
I tried to find a way to remove the need for the ":" but I couldn't. 
[Answer]
# [Raku](https://github.com/nxadm/rakudo-pkg), ~~14~~ 11 bytes
```
,1...&say^1
```
[0Try it online!](https://tio.run/##K0gtyjH7b/Bfx1BPT0@tOLEyzvD/fwA) [1Try it online!](https://tio.run/##K0gtyjH7b/hfx1BPT0@tOLEyzvD/fwA "Perl 6 – Try It Online")
Abuses the range operator to loop infinitely and the XOR Junction (`^`) to print and to evaluate if the range should stop.
[Answer]
# [Python 3](https://docs.python.org/3/), 37 bytes
```
and exec('while 1:print(1)');print(0)
```
0: [Try it online!](https://tio.run/##K6gsycjPM/7/3yAxL0UhtSI1WUO9PCMzJ1XB0KqgKDOvRMNQU13TGsI00Pz/HwA "Python 3 – Try It Online")  
1: [Try it online!](https://tio.run/##K6gsycjPM/7/3zAxL0UhtSI1WUO9PCMzJ1XB0KqgKDOvRMNQU13TGsI00Pz/HwA "Python 3 – Try It Online")
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 3 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
Äo↑
```
[Try `0Äo↑` online.](https://tio.run/##y00syUjPz0n7/9/gcEv@o7aJ//8DAA)  
[Try `1Äo↑` online.](https://tio.run/##y00syUjPz0n7/9/wcEv@o7aJ//8DAA)
**Explanation:**
```
1     # Push 1
   ↑  # While true without popping,
 Ä    # by using a single builtin as inner block:
  o   #  Print with trailing newline without popping
0     # Push 0
   ↑  # While true without popping
      # (output the entire stack joined together implicitly as result)
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 21 bytes
```
0|?{$_}|%{for(){1}};0
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/37DGvlolvrZGtTotv0hDs9qwttba4P9/AA "PowerShell – Try It Online")
[Answer]
# [Keg](https://github.com/JonoCode9374/Keg), 4 bytes
```
{:|④
```
[Try it online!](https://tio.run/##y05N//@/2qrm0cTF////180oAgA "Keg – Try It Online")
It seems I'm a bit late to the party! ¯\\_(ツ)\_/¯
~~Anyhow, this is simply a modification of the usual truth machine~~ This is literally the same truth machine as it would be if we didn't have to place the digit at the start. Funny how implicit input works.
By this, I mean it doesn't matter if y'all place the digit at the start or you place it in input. 
(⌐■◡■)
[Answer]
# JavaScript, 34 bytes
```
?(_=>{for(;;)alert(1)})():alert(0)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNEtLshMSS3Kzc/LTq38n5iTWlRim5yfV5yfk6qXk5/@314j3tauOi2/SMPaWhMsrWGoWaupoWkF4Rho/v8PAA "JavaScript (SpiderMonkey) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 6 bytes
```
1ＷΣ⊟ＫＡＤ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvREPJUEnTmqs8IzMnVUEjuDRXIyC/QCMgNTXbMSdHQxMIFFxKcws0NK3///@vW5YDAA "Charcoal – Try It Online") Link is to verbose version of code.
```
0ＷΣ⊟ＫＡＤ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvREPJQEnTmqs8IzMnVUEjuDRXIyC/QCMgNTXbMSdHQxMIFFxKcws0NK3///@vW5YDAA "Charcoal – Try It Online") Link is to verbose version of code.
Explanation: The leading `1` or `0` simply prints literally to the canvas. There then follows a `while` loop, the condition of which is the digital sum of the last character on the canvas. Thus if this is zero, the loop never gets off the ground, and the canvas gets implicitly output with the `0` still on it. However, if this is a non-zero digit, such as `1`, then the loop will dump a copy of the canvas for ever. (Note that the `dump` command has a rate limit on it, so that TIO will time out before the output reaches the size limit.)
There are a few variants with the same byte count, such as using `Cast` rather than `Sum`, or `Maximum` or `Minimum` rather than `Pop`, or even by using `Count` or `Find` instead.
[Answer]
# [Alchemist](https://github.com/bforte/Alchemist), 27 bytes
```
a->a+Out_b
_+0a->a+b
a+b->_
```
[Try it online with 0!](https://tio.run/##S8xJzkjNzSwu@f/fIFHXLlHbv7QkPokrXhvCS@ICYl27@P//AQ "Alchemist – Try It Online")
[Try it online with 1!](https://tio.run/##S8xJzkjNzSwu@f/fMFHXLlHbv7QkPokrXtsAzEviAmJdu/j//wE "Alchemist – Try It Online")
This was a bit tricky. Every execution path up to the first application of the first line must be possible in both programs, and the two possible patterns in the first line are mutually exclusive. Hence, in order for the program to work, execution up to that point must be non-deterministic. This program swaps infinitely between two states until the first line is applied.
```
0a->a+Out_b    # the 0 version: from the initial state, add an a to halt and output 0
1a->a+Out_b    # the 1 version: from the a+b state, output 1 and leave the state unchanged
_+0a->a+b      # From the initial state, move to the a+b state
a+b->_         # From the a+b state, move to the initial state
```
A deterministic solution is possible by starting the first line with a two-digit number, but this is [14 bytes longer](https://tio.run/##S8xJzkjNzSwu@f/fMFE7WdcuiSte184QxOZK0jZIBApo@5eWxCcBeUAOmPn//3/dFAA "Alchemist – Try It Online").
[Answer]
# [PHP](https://php.net/), 24 bytes
```
?:die(0.);for(;;)echo 1;
```
Uses ternary condition knowing that in PHP one of the alternatives can be empty and i doesn't need to be assigned to a variable.
0: [Try it online!](https://tio.run/##K8go@G9jXwAkDeytUjJTNQz0NK3T8os0rK01U5Mz8hUMrf//BwA "PHP – Try It Online")
1: [Try it online!](https://tio.run/##K8go@G9jXwAkDe2tUjJTNQz0NK3T8os0rK01U5Mz8hUMrf//BwA "PHP – Try It Online")
Edit: had to add `'0'` to properly echo zero
Edit2: Had forgotten that `die` was synonym of `exit` (thanks manual)
Edit3: saved 1 byte with `for(;;)` instead of `while(1)`
Edit4: saved 1 byte with `die(0.)` instead of `die('0')` thanks to @Christoph
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), 5 bytes
```
^O?@u
```
0 [Try it online!](https://tio.run/##Sy5Nyqz4/98gzt/eofT/fwA "Cubix – Try It Online")
1 [Try it online!](https://tio.run/##Sy5Nyqz4/98wzt/eofT/fwA "Cubix – Try It Online")
Maps onto the cube like 
```
  0
^ O ? @
  u
```
* `^` Redirect up onto the top face
* `0` or `1` pushed to the stack
* `?` test
	+ `uO?@` if `0` then u-turn onto the integer output pass through the test again and halt
	+ `O^` if `1` output the integer and redirect up again
[Answer]
# [Turing Machine Code](http://morphett.info/turing/turing.html), ~~29~~ bytes or 28 bytes
With the strange rule that the leading '0' or '1' doesn't count towards the byte count.
```
0 0 1 * 1
* _ 0 * 1
* 1 1 r 1
```
[Try '0' online!](http://morphett.info/turing/turing.html?e5750226d485c40676e8bfce2a18ffab)
```
1 0 1 * 1
* _ 0 * 1
* 1 1 r 1
```
[Try '1' online!](http://morphett.info/turing/turing.html?bc348194dbef0b4ddae4c81dbfff4544)
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~16~~ 15 bytes
*-1 byte thanks to Jo King*
```
&&1 xx*X[&put]$
```
[Try0 it online!](https://tio.run/##K0gtyjH7/99ATc1QoaJCKyJaraC0JFbl/38A "Perl 6 – Try It Online")  
[Try1 it online!](https://tio.run/##K0gtyjH7/99QTc1QoaJCKyJaraC0JFbl/38A "Perl 6 – Try It Online")
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~15~~ 9 bytes
```
?\0n;
n1<
```
[Try it online!](https://tio.run/##S8sszvj/3z7GIM@aK8/Q5v9/AA "><> – Try It Online")
* -6 bytes thanks to JoKing
My first fish program~~, doesn't beat the other one but I wanted to post it anyway.~~ Beats the other one now!
### Explanation:
For 0:  
`0?` skip the next command  
`0` push `0` to the stack  
`n` output the top of the stack  
`;` terminate  
For 1:  
`1?` don't skip the next command (no-op)  
`\` mirror down  
`>` switch direction to forward  
`1` push `1` to the stack  
`n` output, then wrap round
[Answer]
# [Python 3](https://docs.python.org/3/), 38 bytes
```
0 or print(0)or exit()
while 1:print(1)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/30Ahv0ihoCgzr0TDQBPITK3ILNHQ5CrPyMxJVTC0gsgYav7/DwA "Python 3 – Try It Online")
```
1 or print(0)or exit()
while 1:print(1)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/31Ahv0ihoCgzr0TDQBPITK3ILNHQ5CrPyMxJVTC0gsgYav7/DwA "Python 3 – Try It Online")
---
If output to STDERR is allowed (30 bytes):
```
0 or exit('0')
while 1:print(1)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/30Ahv0ghtSKzREPdQF2TqzwjMydVwdCqoCgzr0TDUPP/fwA "Python 3 – Try It Online")
---
If output as exit code is allowed (28 bytes):
```
0 or exit(0)
while 1:print(1)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/30Ahv0ghtSKzRMNAk6s8IzMnVcHQqqAoM69Ew1Dz/38A "Python 3 – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 17 bytes
```
>0?loop{p 1}:p(0)
```
[Try it online!](https://tio.run/##KypNqvyfnJ@Saquurv7fzsA@Jz@/oLpAwbDWqkDDQPM/UJQrtSwxR8HeQBukTK@4pCizACpkiCT0HwA "Ruby – Try It Online")
[Answer]
# TI-BASIC, 10 bytes
```
Repeat not(Ans:Disp Ans:End:"
```
Add either `0:` or `1:` to the beginning of the code to get the desired output.  
Output is either just 0 or an infinite amount of 1s.
`Repeat`  loops until its condition is true and ignores the condition for the first loop.  
Thus, `not(Ans` will be 1 if `0:` is added and 0 if `1:` is added.
An empty string is added to the end of the program to prevent it from printing `Done`.
**Examples:**
prgmA: `0:Repeat not(Ans:Disp Ans:End:"`
prgmB: `1:Repeat not(Ans:Disp Ans:End:"`
```
prgmA
              0
prgmB
              1
              1
              1
              1
              1
              1
              1
```
**Note:** TI-BASIC is a tokenized language. Character count does *not* equal byte count.
]