[Question]
  [
You will be given a string. It will contain 9 unique integers from 0-9. You must return the missing integer. The string will look like this:
```
123456789
 > 0
134567890
 > 2
867953120
 > 4
```
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~18~~ 16 bytes
+beauty thanks to @Sarge Borsch
```
`99066**2`.strip
```
[Try it online!](https://tio.run/nexus/python2#S7ON@Z9gaWlgZqalZZSgV1xSlFnwv6AoM69EIU0jM6@gtERDU/O/uoWZuaWpsaGRgToA "Python 2 – TIO Nexus")
`99066**2` is just a shorter way to generate a string that contains 0~9
[Answer]
# [Python](https://docs.python.org/2/), 22 bytes
```
lambda s:-int(s,16)%15
```
[Try it online!](https://tio.run/nexus/python2#JY5LCsJAEETX5hS9kShEmJ6e/gVyEnUR0YCgUTK5f0zG5aPqUTV0l@XVv2/3HnJ7eo7zITcoxz3yMj/ynKGDc52EjTwq1g3UFFwtSeQNDJMKOYcNJLkpY4gbRCH2YH9HNBk6xVJjJccYLBXAIBYTeXFYAqpTSXRdRbLVuVbV8Jkgw3OEcqqtdt9p/QrDIR@XHw "Python 2 – TIO Nexus")
An arithmetic solution. Interprets the input string as hex, negates it, and takes the result modulo 15.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 4 bytes
### Derived function
```
⎕D∘~
```
`⎕D` **D**igits
`∘` (ties a left argument to the following dyadic function to create a monadic function)
`~` except [the argument]
[Try it online!](https://tio.run/nexus/apl-dyalog#@5/2qG3Co76pLo86ZtT9/5@moG5oZGxiamZuYanOBeJBOQZgnoWZuaWpsaGRgToA "APL (Dyalog Unicode) – TIO Nexus")
---
### Function train
```
⎕D~⊢
```
`⎕D` **D**igits
`~` except
`⊢` the right argument
[Try it online!](https://tio.run/nexus/apl-dyalog#@5/2qG3Co76pLnWPuhb9/5@moG5oZGxiamZuYanOBeJBOQZgnoWZuaWpsaGRgToA "APL (Dyalog Unicode) – TIO Nexus")
---
### Explicit program
```
⎕D~⍞
```
`⎕D` **D**igits
`~` except
`⍞` character input
[Try it online!](https://tio.run/nexus/apl-dyalog#e9TRnvb/Ud9Ul7pHvfP@P@po/5/GZWhkbGJqZm5hyQVkQ5kGQLaFmbmlqbGhkQEA "APL (Dyalog Unicode) – TIO Nexus")
[Answer]
# [Haskell](https://www.haskell.org/), ~~24~~ 23 bytes
```
(477-).sum.map fromEnum
```
[Try it online!](https://tio.run/nexus/haskell#@59mq2Fibq6rqVdcmquXm1igkFaUn@uaV5r7PzcxM0/BViEzryS1KDG5REFFoTgjv1xBTyHtv6GRsYmpmbmFJQA "Haskell – TIO Nexus") Usage: `(477-).sum.map fromEnum $ "123456890"`. 477 is the sum of the character codes of the digits 1 to 9, excluding 0. This anonymous function computes 477 minus the sum of all digit character codes to find the missing one.
Turning the char digits to ints is one byte longer:
```
(45-).sum.map(read.pure)
foldl(\a b->a-read[b])45
```
[Try it online!](https://tio.run/nexus/haskell#@59mm5afk5KjEZOokKRrl6hblJqYEp0Uq2li@j83MTNPwVYhM68ktSgxuURBRaE4I79cQU8h7b@hkbGJqZm5hQEA "Haskell – TIO Nexus")
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~48~~ ~~38~~ 36 + 3 = 39 bytes
*10 bytes saved thanks to DJMcMayhem!*
```
((([]())[]{}){()()({}[()])}{}[{{}}])
```
[Try it online!](https://tio.run/nexus/brain-flak#@6@hoREdq6GpGR1bXatZraEJhNW10RqasZq1QLq6urY2VvP/fwtDI2MTAzNzy/@6yQA "Brain-Flak – TIO Nexus")
## Explanation
The sum of all the digits in Ascii is 525. This program sums up the input and subtracts it from 525 to get the missing digit.
```
((([]())[]{}){()()({}[()])}{}      )
```
Will push 525. This takes advantage of the fact that we know there will be 9 elements of input to begin with. This means that `[]` evaluates to 9 which allows us to get to large numbers like 525 quickly.
Next we have the bit:
```
                             [{{}}]
```
which will sum up the inputs and subtract it from the total.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
ØDḟ
```
Simply filters (`ḟ`) the input string from **“0123456789”** (`ØD`).
[Try it online!](https://tio.run/nexus/jelly#@394hsvDHfP///@vZGFmbmlqbGhkoAQA "Jelly – TIO Nexus")
[Answer]
# Ruby, 14
Sums the ascii codes and subtracts from 48\*9+45
```
->s{477-s.sum}
```
Use like this
```
f=->s{477-s.sum}
puts f["123456789"]
```
[Answer]
# JavaScript (ES6), 26
*Edit* 1 byte save thx @Neil, with a much more smarter trick
Xoring all the values from 1 to 9 gives 1. Xor 1 one more time and the result is 0. So, if any single value is missing, the result will be the missing value.
```
s=>eval([1,...s].join`^`)
```
**Test**
```
f=s=>eval([1,...s].join`^`)
function go() {
  var i=I.value;
  O.textContent = f(i)
}  
go()
```
```
<input oninput='go()' value='012987653' id=I>
<pre id=O></pre>
```
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~27 21~~ 19 bytes
-6 Thanks to Basic Sunset  
-2 Thanks to Martin Ender
```
.
$*_5$*
+`_1|1_
1
```
[Try it online!](https://tio.run/nexus/retina#@6/HpaIVb6qixaWdEG9YYxjPxWX4/7@hkbGpmbmFpQEA "Retina – TIO Nexus")
Replace every digit with that many `_`s and 5 `1`s:
```
.
$*_5$*
```
Remove all of the `_`s and a `1` for each:
```
+`_1|1_ 
```
Count the number of `1`s left:
```
1
```
[Answer]
# Brainfuck, 17 15 bytes
```
-[-[->-<],]>++.
```
[Try it out here](https://copy.sh/brainfuck/?c=LVstWy0-LTxdLF0-Kysu).
*This solution works on standard Brainfuck (8-bit cells) only, as it relies on wrapping.*
It's a rare day when Brainfuck can actually compete, but this challenge just happened to line up with the BF spec pretty well! 
Instead of straight-up breaking down this answer, I'd like to step through the iterations I took, because I think it would be more understandable (and more interesting).  
Note: this solution is inspired largely by [Wheat Wizard's Brain-Flak answer](https://codegolf.stackexchange.com/questions/114060/output-the-missing-integer/114063#114063). 
## Explanation
## Step 1, 26 bytes
In his answer, Wheat Wizard pointed out that the sum of the ASCII values from 0-9 sum to 525. And since standard Brainfuck only has a notion of [0,255], this makes the value 525 % 256 = **13**. That is to say, subtracting the ASCII values of the input from 13 nets you the missing digit. 
The first version of this program was:  
 1. Put 13 in the first cell  
 2. Take inputs into the second cell  
 3. Subtract the second cell from the first cell  
 4. Jump to 2 if there are inputs remaining  
 5. Print the first cell 
And here's the code for the simple solution:
```
+++++++++++++ #Set the first cell to 13  
>,            #Take inputs into the second cell  
[[<->-],]     #Subtract the second cell from the first cell and repeat until inputs are over  
<.            #Print the first cell  
```
## Step 2, 19 bytes
As pointed out in his answer, since we know the input will be exactly length 9, we can use that value as a constant, and eliminate that long string of +'s right at the beginning.  
It also doesn't matter at what point we add 13 (thanks, commutative property!), so we'll mix it in with the subtraction and printing steps. 
```
,        #Take input to enter the loop
[[->-<], #Subtract the first cell from the second cell 
>+<]     #Add 1 for each input; totaling 9
>++++    #Add the missing 4 to make 13
.        #And print
```
This was my original answer to this problem, but we can do better. 
## Step 3, 17 bytes
Interestingly enough, the previous answer works even if we begin with a + instead of a ,
```
+[[->-<],>+<]>++++.
```
Brainfuck required *something* in a cell in order to begin a loop. We naively added that extra 4 in the end, when it could have gone in other places. 
```
-[[->-<],>+<]>++.
```
With some *totally intentional* (read: trial and error) loop trickery, starting off the program with a - leads to two interesting results:
1. One gets added to the second cell (saving 1 byte at the end).
2. The loops runs one extra time, totaling 10 instead of 9 (saving another 1 byte).
1 + 10 + 2 = 13, and we end up with the original answer. 
Looking back on it, this is probably an excessive write-up for such a simple Brainfuck program.
## Step 4, 15 bytes
After thinking about this solution a bit more, I was able to cut off 2 bytes. 
I wanted to clarify something about the previous step:  
The minus to enter the loop *effectively* adds 1, but what it's actually doing is subtracting 255 from the second cell (resulting in 1).
It's obvious in retrospect, but subtracting 1 from the first cell is the same as adding 1 to the second cell (because everything in the first cell gets subtracted from the second cell.) 
```
-[-[->-<],]>++.
```
I was able to remove the ">+<" by adding a "-" at the beginning of the first loop. It has to go there, and not where the ">+<" was, because the program will loop infinitely otherwise.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes
```
45¹SO-
```
[Try it online!](https://tio.run/nexus/05ab1e#@29iemhnsL/u//8WZuaWpsaGRgYA "05AB1E – TIO Nexus")
```
45     # Push 45
  ¹    # push input
   S   # Split
    O  # Sum
     - # Subtract (45 - sum)
```
[Answer]
# Mathematica, 25 bytes
```
477-Tr@ToCharacterCode@#&
```
Pure function taking a string as input and returning an integer.
Mathematica has long command names and is reluctant to convert between strings and integers, which makes it particularly bad at this challenge. The best I could find was the algorithm from [Level River St's Ruby answer](https://codegolf.stackexchange.com/a/114091/56178), which does a computation based on the total of the ASCII codes of the input string; in Mathematica, this uses only one long command name.
[Answer]
## JavaScript (ES6), ~~31~~ ~~29~~ ~~28~~ 22 bytes
```
s=>(15-`0x${s}`%15)%15
```
Port of @xnor's Python answer, except that JavaScript only has a remainder operator rather than a modulo operator, so I can't do it in a single step. Edit: Saved 6 bytes thanks to @Arnauld.
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 22 bytes
```
@(x)setdiff('0':'9',x)
```
[Try it online!](https://tio.run/nexus/octave#@@@gUaFZnFqSkpmWpqFuoG6lbqmuU6H5PzGvWEPd0NjE1MzcwtJAXfM/AA "Octave – TIO Nexus")
[Answer]
# PHP, 27
```
<?=trim(32043**2,$argv[1]);
```
uses the trick from [Rod's answer](https://codegolf.stackexchange.com/a/114070/29637) to generate a string containing all digits then removes all digits except for the missing one.
---
PHP, 41
```
for($b=1;$i<9;$b^=$argv[1][$i++]);echo$b;
```
This one uses *xor* because I haven't seen it yet.
[Answer]
## Bash + coreutils, 19 bytes
I found a ~~shorter~~ bash solution, that uses an interesting checksum approach:
```
sum -s|dc -e524?--P
```
**[Try it online!](https://tio.run/nexus/bash#@19cmqugW1yTkqygm2pqZGKvqxvw/7@FmbmlqbGhkQEA)**
**Explanation:**
The `sum` command prints a checksum and a block count. I don't know many details, but using the option `-s` (System V algorithm) will make the checksum equal to the ASCII sum of each input character code. As such, the checksum remains constant when the order of the same input characters changes.
Given `867953120` as test case (last example), here is how the script works:
* `sum -s` outputs `473 1`. If no integer was missing, the checksum would have been 525.
* `dc -e524?` pushes 524 and then the pipe input. The stack is: `1 473 524`. The idea is to subtract the checksum from 525, but since sum outputs 1 as well, I need to work with it.
* `--P`. After applying the two subtractions (524-(473-1)), the stack is: `52`. With 'P' I print the character with that ASCII code: `4`, the missing digit.
[Answer]
# Fortran 95, ~~146~~ 128 bytes
```
function m(s)
character(len=10)::s,t
t='0123456789'
do j=1,10
k=0
do i=1,9
if(s(i:i)==t(j:j))k=1
end do
if(k==0)m=j-1
end do
end
```
Not very short, I'm afraid.
**Ungolfed:**
```
integer function m(s)
    implicit none
    character(len=9)::s
    character(len=10)::t
    integer:: i, j, k
    t='0123456789'
    do j=1,10
        k=0
        do i=1,9
            if (s(i:i) == t(j:j)) k=1
        end do
        if (k==0) m=j-1
    end do
end function m
```
[Answer]
# Bash (+utilities), ~~22~~, 19 bytes
* Use `seq` instead of brace expansion, -3 bytes (Thx @Riley !)
```
seq 0 9|tr -d \\n$1 
```
**Test**
```
$seq 0 9|tr -d \\n123456789
0
```
[Try It Online!](https://tio.run/nexus/bash#@1@cWqhgoGBZU1KkoJuiEBOTp2L4//9/CzNzS1NjQyODr3n5usmJyRmpAA)
[Answer]
# Google Sheets, ~~39~~ 33 bytes
> 
> Input is entered into cell **`A1`**.
> 
> 
> 
**Code:**
```
=REGEXEXTRACT(4&2^29,"[^"&A1&"]")
```
*Saved 6 bytes thanks to Steve Kass.*
**Previous Code:**
```
=REGEXEXTRACT("0123456789","[^"&A1&"]")
```
**Result:**
[![enter image description here](https://i.stack.imgur.com/NSF5r.png)](https://i.stack.imgur.com/NSF5r.png)
[Answer]
# [Bash](https://www.gnu.org/software/bash/), ~~36~~ 30 bytes
```
(fold -1;seq 0 9)|sort|uniq -u
```
[Try it online!](https://tio.run/##Rck5DoMwFEXRPqt4RYqkQPKAJ7EVGic2AinyFzh03rvToPzu6N5XrGtf6EDEViCVHo11PkBeEPDWBaOlElD/xlcqlmaNLMOyLMfyrDAh0S2/V8I9omHuj4U@CYOcat4hEJ6t0vFtZ9l2DGdPVHL/AQ "Bash – Try It Online")
~~Posting to get golfing tips over this.~~
Thanks @DigitalTrauma, big fan ;)
`fold -1` writes one char of input per line
`seq 0 9` writes 0..9 one per line after this.
Those lines are fed to `sort` and filtered by `uniq -u` displaying only not duplicated lines.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 30 bytes
```
param($n)0..9|?{$n-notmatch$_}
```
[Try it online!](https://tio.run/nexus/powershell#@1@QWJSYq6GSp2mgp2dZY1@tkqebl1@Sm1iSnKESX/v//391CzNzS1NjQyMDdQA "PowerShell – TIO Nexus")
Takes input `$n`, constructs a range `0..9` (i.e., `0, 1, 2 ... 9`), then uses a `Where-Object` clause (the `|?{...}`) to pull out the number that does regex `-notmatch`. That's left on the pipeline, output is implicit.
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 5 bytes
```
A,sq-
```
[Try it online!](https://tio.run/nexus/cjam#@@@oU1yo@/@/hZm5pamxoZEBAA "CJam – TIO Nexus")
```
A,     e# The range from 0 to 9: [0 1 2 3 4 5 6 7 8 9]
  s    e# Cast to a string: "0123456789"
   q   e# The input
    -  e# Remove all characters from the range that are in the input
       e# Implicit output
```
[Answer]
# [GNU sed](https://www.gnu.org/software/sed/), 36 bytes
Includes +1 for `-r`
```
s/$/0123456789/
:
s/(.)(.*)\1/\2/
t
```
[Try it online!](https://tio.run/nexus/sed#@1@sr6JvYGhkbGJqZm5hqc9lxVWsr6GnqaGnpRljqB9jpM9V8v@/hZm5pamxoZHBv/yCksz8vOL/ukUA "sed – TIO Nexus")
```
s/$/0123456789/ # Append 0123456789
:               # Start loop
s/(.)(.*)\1/\2/ # remove a duplicate character
t               # loop if something changed
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes
```
žhISK
```
[Try it online!](https://tio.run/nexus/05ab1e#@390X4ZnsPf//4bGJqZm5haWBgA "05AB1E – TIO Nexus")
**Explanation**
```
žh     # from the string "0123456789"
    K  # remove
  IS   # each digit of the input
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog) (2), 5 bytes
```
ẹ:Ị↔x
```
[Try it online!](https://tio.run/nexus/brachylog2#@/9w106rh7u7HrVNqfj/X8nCzNzS1NjQyEDpfxQA "Brachylog – TIO Nexus")
Arguably should be shorter (I'm still confused as to why the `ẹ` is necessary), but this is the best I could do.
## Explanation
```
ẹ:Ị↔x
ẹ      Split the input into a list of characters
 :Ị    Pair that list with the string "0123456789"
   ↔x  Remove all elements of the list from the string
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 bytes
```
¬x n45
```
[Try it online!](https://tio.run/nexus/japt#@39oTYVCnonp//9KhkYmpmbmFpYGSgA "Japt – TIO Nexus")
### Explanation:
```
¬x n45
   n45     // 45-
¬          //    Split the input into an array "123" → ["1","2","3"]
 x         //    Return the sum of all the items ["1","2","3"] → 6
           // 45 - 6 = output
```
[Answer]
# Common Lisp, 47 bytes
```
(lambda(s)(- 45(reduce'+ s :key'digit-char-p)))
```
Ungolfed:
```
(lambda (s) (- 45 (reduce '+ s :key 'digit-char-p)))
```
Explaination:
```
(reduce '+ s :key 'digit-char-p)
```
This loops through the chars in `s`, converts them to digits, and adds them. Digit-char-p, conveniently, return the number of the char as its "true" value, so it can be used as a test or a conversion.
```
(- 45 ...)
```
Subtract from 45 gives back the digit that was missing from the input.
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), 18 Bytes
```
5v&;52/ni?@.>!&oW+
```
Expanded
```
    5 v
    & ;
5 2 / n i ? @ .
> ! & o W + . .
    . .
    . .
```
[Try it here](https://ethproductions.github.io/cubix/?code=NXYmOzUyL25pP0AuPiEmb1cr&input=ODc2NTkxMzIw&speed=20)
Uses the same sort of method as this [brain-flak](https://codegolf.stackexchange.com/a/114063/31347) answer.
Create the value -525 on the stack by pushing 5, 2, concatenate, push 5, concatenate and negate.  
Then repeatably get input and add until end of input is hit.  
Remove the last input, negate(make positive) the last add result, output the character and halt.
The reason for working from -525 up is that the character output is hit for each input iteration. Since the value is negative, nothing is output until the loop is exited and the negative value is made positive.
[Answer]
# PHP, 37 bytes
```
<?=45-array_sum(str_split($argv[1]));
```
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), ~~12~~ 10 bytes
```
Cdi?B%-B%p
```
[Try the dc version online!](https://tio.run/nexus/dc#@@@ckmnvpKrrpFrw/7@hkbGBqYm5mQUA "dc – TIO Nexus")
This uses the fact that the sum of the digits from 0 to 9 is 45, which is 1 more than a multiple of 11.
The program works by viewing the input as a base 12 number, finding its remainder when divided by 11, and subtracting that from 12 (to find the missing digit). The only catch is that if 0 or 1 is the missing digit, this would give an answer of 11 or 12, respectively, so I mod out by 11 one additional time at the end to take care of those cases.
---
This yields a short bash solution also:
# [Bash](https://www.gnu.org/software/bash/) + Unix utilities, ~~17~~ 15 bytes
```
dc -eCdi?B%-B%p
```
[Try the bash version online!](https://tio.run/nexus/bash#@5@SrKCb6pySae@kquukWvD/v5GBmaGlqbmFCQA "Bash – TIO Nexus")
]