[Question]
  [
## Challenge
Given a whole number divisible by 9 and one missing digit, find the missing digit.
The missing digit may be represented by any character other than the digits 0-9 as long as it is consistent.
If the missing digit could be 0 or 9, output something to signify so.
Assume the user is intelligent enough to put only one missing digit and one number etc.
## Test Cases
In the test cases the missing digit is represented by a question mark
```
123? -> 3
?999 -> 0 or 9
?0023 -> 4
000?1 -> 8
```
  
[Answer]
# [Python](https://docs.python.org/2/), 21 bytes
```
lambda s:-int(s,19)%9
```
[Try it online!](https://tio.run/##HYtBCoAgEAC/spdYA4PVThvU3T90MUoKSiW99HorTzMMTHzyHrwubpzLaa9ltZCG7vBZJKm4bbi4cEPeUobDAyrdG5SAhpkriXT/CxEZVQsO8f7@@kjsJpRO/N6WFw "Python 2 – Try It Online")
I used `I` to represent a missing digit.
[Answer]
## [Alice](https://github.com/m-ender/alice), 12 bytes
```
/o&
\i@/+R9%
```
[Try it online!](https://tio.run/##S8zJTE79/18/X40rJtNBXzvIUvX/f3sDAyNjAA "Alice – Try It Online")
Outputs `0` if the result can be either 0 or 9.
### Explanation
```
/   Switch to Ordinal mode.
i   Read all input as a string.
&   Fold the next operation over the characters of this strings.
/   Switch to Cardinal mode (not an operation).
+   Add. Implicitly converts each character to the integer value it represents
    and adds it to the top of the stack. The top of the stack is initially, implicitly
    zero. When the character is "?", it is simply discarded, which adds the top of
    the stack to another implicit zero beneath, so the "?" is effectively skipped.
R   Negate. Multiplies the sum by -1.
9%  Modulo 9. This gives the result.
\   Switch to Ordinal mode.
o   Implicitly convert the result to a string and print it.
@   Terminate the program.
```
[Answer]
# JavaScript (ES6), 40 bytes
Outputs 9 if could be 0 or 9.
```
f=_=>9-([..._].reduce((a,b)=>a+~~b,0)%9)
```
[Answer]
# Japt, 7 bytes
Tried a few solutions but the shortest was similar to most others except we don't need to replace the `?` at the start.
Can take any non-numeric character as the missing digit. Outputs `0` when the solution can be that or `9`.
```
¬x*J u9
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=rHgqSiB1OQ==&input=IjAwMD8xIg==)
---
## Explanation
Implicit input of string `U`. `¬` splits to an array of individual characters, `x` reduces the array by addition ignoring any non-numeric elements, `*J` multiplies each element by -1 and `u9` gets the positive modulus of the result.
[Answer]
# JavaScript (ES6), 18 bytes
Expects a `+` as the missing digit. Returns `9` for *0 or 9*.
```
s=>9-eval(9+s+9)%9
```
### Test cases
```
let f =
s=>9-eval(9+s+9)%9
console.log(f('123+'))  // -> 3
console.log(f('+999'))  // -> 0 or 9
console.log(f('+0023')) // -> 4
console.log(f('000+1')) // -> 8
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~7~~ 6 bytes
An output of `0` means the result could be either **0** or **9**.
```
þSO(9%
```
[Try it online!](https://tio.run/##MzBNTDJM/f//8L5gfw1L1f//7Q0MjIwB "05AB1E – Try It Online")
or as a [Test suite](https://tio.run/##MzBNTDJM/V9TVvn/8L5gfw1L1f@VSof3Wykc3q@k89/QyNiey97S0pLL3sDAyJjLwMDA3hAA)
**Explanation**
```
þ        # remove non-digits from input
 S       # split to list of digits
  O      # sum list
   (     # negate
    9%   # mod by 9
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~44~~ ~~41~~ 35 bytes
-6 bytes thanks to RiaD
```
lambda n:-sum(ord(c)-3for c in n)%9
```
[Try it online!](https://tio.run/##HYrBCoUgEEV/ZTaPUVCYdGVQX5KLXj0pqDHUFn29D1udcy73esoW2dQwTPWYz@86A/c636eIaRWL1DbEBAvsDCw/rrYqv1zagJ2xHhWgd869JDK2CRH5Dvsr7Vzeu0I9ogqiuax/ "Python 2 – Try It Online")
Users `]` for missing digit.  
Outputs `0` if the missing digit could be 0 or 9.
[Answer]
# Pyth, ~~9~~ 7 bytes
```
%_s-Qd9
```
Uses space as the delimiter and returns 0 if the result could be 0 or 9.
[Try it online](http://pyth.herokuapp.com/?code=%25_ssMcQd9&input=%22123%2033%22&debug=0)
### Explanation
```
%_s-Qd9
   -Qd   Remove the space from the input.
  s      Convert it to an integer.
%_    9  Negate mod 9.
```
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 59 bytes
```
0*[].
X*[H|T]:-between(0,9,H),U is mod(X+H,9),U*T.
+X:-0*X.
```
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/30ArOlaPK0Ir2qMmJNZKNym1pDw1NU/DQMdSx0NTJ1Qhs1ghNz9FI0LbQ8cSyNcK0ePSjrDSNdCK0Pv/XzvaUMdIJ0LHLFYPAA "Prolog (SWI) – Try It Online")
Yay for Logical programming!
## Explanation
First we make a predicate `*`, which holds when applied to zero and the empty list. Our predicate also holds when the front of the list is between 0 and 9 and when we add the leading digit mod 9 the predicate holds.
We then define `+` to just be this predicate with `0` as the first argument. That is we want the digital sum to be a multiple of 9.
Prolog does all the grunt work of actually finding solutions for us.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~11~~ ~~9~~ 6 bytes
```
|0SN%9
```
### Explanation
```
|0     # Read input while removing non-digits (question marks) and removing leading zeros
  S    # Sum the digits
   N   # Negate
    %9 # Mod by 9
```
An output of 0 means the result could be either 0 or 9.
[Try it online!](https://tio.run/##y0rNyan8/7/GINhP1fL////2BgZGxgA "Jelly – Try It Online")
Saved 2 bytes thanks to [Mr. Xcoder](https://codegolf.stackexchange.com/users/59487/mr-xcoder). When using the Each quick (`€`) during evaluation, splitting the number into digits was redundant.
Saved 3 bytes thanks to [Dennis](https://codegolf.stackexchange.com/users/12012/dennis). Can bitwise OR the input with 0 instead of manually parsing the input as a number while removing leading zeros and non-digits.
[Answer]
# [Befunge-93](https://github.com/catseye/Befunge-93), 16 bytes
```
1+!_#@3#.--9%~:#
```
[Try it online!](https://tio.run/##S0pNK81LT/3/31BbMV7ZwVhZT1fXUrXOShkoYmSsBQA "Befunge-93 – Try It Online\" \"Befunge-93 – Try It Online")
A one line version of [James Holderness’ Befunge answer](https://codegolf.stackexchange.com/a/151536/76162) that manages to shave off two bytes. This essentially compresses the code down to one line, reverses the direction and takes advantage of the fact that Befunge doesn’t skip at the end of the line. He suggested I post a separate answer with an explanation. The code takes an \* as representing the missing digit and outputs a 9 for either 0 or 9. 
### How It Works
```
1+!_  3  --9% Initialises the pointer going right and initialises the digitsum with 3
1+!_         ~: Gets input and checks whether it is end of input (-1)
      3  - Subtract three from the input. 
           This turns the ASCII values of digits into their mod 9 equivalent ("0"(48)=>45(mod 9)=>0)
          -9% Subtract the value from the digitsum and mod it with 9
              This keeps the digitsum as a negative digit greater than -9
              Repeat this until the input ends
Now this is where it gets tricky.
At the end of input, the stack looks like this:
  -(Digitsum%9), Copy of EOF input (-1)
The pointer is moving left from the _
 +!_ Invert the -1 to get 0 and add it to the digitsum (does nothing but get rid of the -1)
1           %~ Adds 1 mod -1 (no input) = 0 to the stack
         --9 Subtracts 9 from 0, yielding -9 and subtracts that from the digitsum. 
             This makes the digitsum positive and equal to 9-(digitsum%9), our desired value
     @  . Finally, print and exit
```
`*` (ASCII value 42) was chosen as the missing character because it counteracts the initial value of the digitsum, 3. 
[Answer]
## LaTeX, many bytes (~~1000~~ ~~628~~ 614)
```
\RequirePackage{expl3}
\ExplSyntaxOn
\tl_new:N \l_divnine_input_tl
\int_new:N \l_divnine_sum_int
\def \getnum {
  \typein [ \l_divnine_input_tl ] { Input\space a\space number }
  \tl_map_function:NN \l_divnine_input_tl \divnine_sum:n
  \int_set:Nn \l_tmpa_int { 9 - \int_mod:nn { \l_divnine_sum_int } { 9 } }
  \typeout
    { The\space missing\space digit\space is:\space
      \int_use:N \l_tmpa_int
      \int_compare:nNnT { \l_tmpa_int } = { 0 } { \space or\space 9 }
    }
}
\cs_new:Nn \divnine_sum:n {
  \regex_match:nnT { \d } { #1 } { \int_add:Nn \l_divnine_sum_int { #1 } }
}
\ExplSyntaxOff
\getnum
\stop
```
## LaTeX, illegible (~~348~~ 334 bytes)
```
\RequirePackage{expl3}\ExplSyntaxOn\int_new:N\1\tl_new:N\2\def\3{\typein[\2]{Input\space a\space number}\tl_map_function:NN\2\4\int_set:Nn\1{9-\int_mod:nn{\1}{9}}\typeout{The\space missing\space digit\space is:\space\int_use:N\1\int_compare:nNnT{\1}={0}{\space or\space9}}}\def\4#1{\regex_match:nnT{\d}{#1}{\int_add:Nn\1{#1}}}\3\stop
```
## LaTeX, 132 bytes
```
\RequirePackage{expl3}\typein[\1].\newcount\2{\ExplSyntaxOn\int_gset:Nn\2{9-\int_mod:nn\19}}\typeout{\the\2 \ifnum\2=9or 0\fi}\stop
```
Only space is allowed as unknown digit in this code.
[Answer]
# [J](http://jsoftware.com/), ~~14~~ 12 bytes
-2 bytes thanks to @BolceBussiere
```
9|9-[:+/"."0
```
I honestly don't know why `"."0` interprets `?` as 0 but it does so on my interpreter and on TIO so I'm not going to question it. (Update: see comments for an explanation why).
This approach very simply takes the sum of the digits, negates it by subtracting from 9, and takes it modulo 9.
[Try it online!](https://tio.run/##y/r/P81Wz7LGUjfaSltfSU/J4H9qcka@QppCallqUaWCuqGRsb26grWCur2lpSWEYWBgZAxmGRgY2Buq/wcA "J – Try It Online")
[Answer]
# [Swift](https://swift.org), 51 bytes
```
{9-Int("0"+$0.filter{"?" != $0})!%9}as(String)->Int
```
[Try it online!](https://tio.run/##Ky7PTCsx@Z@TWqKQpmD7v9pS1zOvREPJQElbxUAvLTOnJLWoWsleSUHRVkHFoFZTUdWyNrFYI7ikKDMvXVPXDqj4fwGQXaKRpqFkaGRsr6SpyQUXsLe0tEQVMDAwMkYRMTAwsDdEVQPi/QcA)
[Answer]
# [Befunge-93 (PyFunge)](https://pythonhosted.org/PyFunge/), ~~22~~ 21 bytes
I realized that I don't need to use `?` to represent the absent digit, so I used one that is a multiple of 9 after subtracting 48: `x`  
This let me golf off the `3+`, but it only saved me 1 byte because of the length of the first line before the conditional :(
---
A port of my Befunge-98 answer:  
5 more bytes in order to check if we've reached EOF,  
1 more byte to push 48 (`"0"` vs `'0`),  
1 more byte to print the answer with `.@`,  
and 1 more byte, because the second line has a space  
for a total of 8 more bytes.
```
~:0`!#|_"0"-+
 @.%9-<
```
[Try it online!](https://tio.run/##S0pNK81LT9W1NNYtqAQz//@vszJIUFSuiVcyUNLV5lJw0FO11LX5/9/QyLgCAA "Befunge-93 (PyFunge) – Try It Online")
Outputs `0` if the missing digit could be 0 or 9.
This only works in the PyFunge interpreter for reasons explained below.
### Explanation
Much of this explanation is copy-pasted from my [Befunge-98 explanation](https://codegolf.stackexchange.com/a/151583/62574), as that program is very similar to this one. shameless plug
In the first line of the program, we sum the digits, including the x, which is treated like a 72 because of it's ASCII value. However, the sum will be the same once we've modded by 9, so this is irrelevant.
```
~:0`!#|_"0"-+    THE FIRST LINE
~                Gets a character from input - If it is negative, we've reached EOF
 :0`!            Pushes 0 if the character is positive, 0 otherwise
     #|_         Goes to the next line if the value if 0
                     This also gets the negative value off the stack by using a |
        "0"-     Subtracts 48 to account for taking in ASCII values
            +    Adds this adjusted value to the sum
```
If we just modded by 9, we would be left with the wrong digit, because we want `9 - (sum % 9)`. However, we can do better than `9\-`, which would subtract the remainder from 9: if we make the sum negative before modding by 9, we will get a positive result, equivalent to `9 - (sum % 9)` in some interpreters. This is what requires us to use the PyFunge interpreters for both Befunge 93 and 98, as it is the only one on TIO that does this. The others give us a value between -8 and 8 instead of 0 and 8
```
 @.%9-<    THE SECOND LINE
      <    Redirects the IP onto this line
     -     Subtracts the sum from an implicit 0, making it negative
   %9      Mods the sum by 9
 @.        Prints the digit and exits
```
[Answer]
# [Befunge-98 (PyFunge)](https://pythonhosted.org/PyFunge/), ~~15~~ 13 bytes
I realized that I don't need to use `?` to represent the absent digit, so I used one that is a multiple of 9 after subtracting 48: `x`  
This let me golf off the `3+`.
```
#v~'0-+
q>-9%
```
[Try it online!](https://tio.run/##S0pNK81LT9W1tNAtqAQz//9XLqtTN9DV5iq007VU/f/f0Mi4AgA "Befunge-98 (PyFunge) – Try It Online")
Uses an `x` as the missing digit, because it's ASCII value is divisible by 9 after subtracting 48 (and it's nice because its commonly used as a variable in math).
Outputs via exit code (because `q` is one byte shorter than `.@`)  
Outputs `0` if the missing digit could be 0 or 9.
This only works in the PyFunge interpreter for reasons explained below.
### Explanation
In the first line of the program, we sum the digits, including the `x`, which is treated like a 72 because of it's ASCII value. However, the sum will be the same once we've modded by 9, so this is irrelevant.
```
#v~'0-+    THE FIRST LINE
#v~        Pushes the next character from input, and goes to the second line on EOF
   '0-     Subtracts 48 to account for taking in ASCII values
      +    Adds this adjusted value to the sum
```
If we just modded by 9, we would be left with the wrong digit, because we want `9 - (sum % 9)`. However, we can do better than `9\-`, which would subtract the remainder from 9: if we make the sum negative before modding by 9, we will get a positive result, equivalent to `9 - (sum % 9)` *in some interpreters*. This is what requires us to use the PyFunge interpreters for both Befunge 93 and 98, as it is the only one on TIO that does this. The others give us a value between -8 and 8 instead of 0 and 8.
```
q>-9%    THE SECOND LINE
 >       Redirects the IP onto this line
  -      Subtracts the sum from an implicit 0, making it negative
   9%    Mods the sum by 9
q        Outputs via exit code, ending the program
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 22 bytes
Uses `'` (any char that has a distance to `0` that is divisible by "0" will do, including `0` itself).
An output of `0` signifies either `0` or `9`.
```
p -(gets.sum+6*~/$/)%9
```
[Try it online!](https://tio.run/##KypNqvz/v0BBVyM9taRYr7g0V9tMq05fRV9T1fL/f3UDAyNjAA "Ruby – Try It Online")
## Explanation
```
p     # print after inspecting
  -(  # unary negative, for reversing result of modulus (a-b%a)
    gets.sum # ascii value of string
    + 6*~/$/ # add six for each size (in chars) of input, so "0" translates to 0
  )%9 # mod 9
      # find remainder after dividing 9
      # except it's inverted so it's remainder to add to divide 9
```
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 13 bytes
```
{9-9|+/,↑⍎¨⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24RqS13LGm19nUdtEx/19h1a8ah3ay1QRkHd0Mj4Ue8adS4gE0hbWlrCmAYGRsZgtoGBAZBrqA4A "APL (Dyalog Unicode) – Try It Online")
The missing digit is `⍬`.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 46, 41 bytes
*-5 thanks to @Unihedron*
```
->s{-s.chars.sum{|i|?<>i ? i.to_i : 0}%9}
```
[Try it online!](https://tio.run/##JYpBCoMwFAX3OcVDEXSREHWVUs1FCsWqoQGrxR8pJebsqdJZDcOs2@MbTXOLvCXPSfTPbiVB28vvdtfX1kLDCrfcLS6QIVMhupEcoUH2ycuq1tBKKWgpqxpSSl0WzCwrzgt2xv8eFoaD93Z4kvozBvAWqTei76YpP0sREjbOA@IP "Ruby – Try It Online")
[Answer]
# Befunge-93, ~~28~~ ~~27~~ ~~19~~ 18 bytes
Credit must go to [Mistah Figgins](/users/62574/mistah-figgins), whose [PyFunge answer](/a/151584/62101) showed me that you didn't need a special check for the missing digit character, if you just made sure the ASCII value was a multiple of nine.
Additional thanks to [Jo King](/users/76162/jo-king) who showed that you didn't need to fully convert the characters to their numeric equivalent, and could simply subtract 3 to get a value that is relative to base 9 (ASCII `0` minus 3 is 45, a multiple of 9).
```
3_v#`0:~--
%9_@.+9
```
[Try it online!](http://befunge.tryitonline.net/#code=M192I2AwOn4tLQolOV9ALis5&input=KjAwMjM)
For this to work, you should use the character `*` for the missing digit (there are others that could also work, but that's the nicest).
Outputs `9` if the missing digit could be 0 or 9.
**Explanation**
```
3             Push 3 onto the stack.
 _            Since this is non-zero, drop the 3 and branch left.
3             Now executing right to left, push 3 again.
        --    Negate twice, leaving the value unchanged as our starting sum.
       ~      Now we start the main loop, reading a character from stdin.
    `0:       Duplicate and check if it's > 0, i.e. not end-of-stream.
 _ #          If so, continue to the left.
3        -    Subtract 3 to make the number relative to base 9.
        -     Then subtract it from the total, and repeat the loop.
  v           Once we reach the end of the input, we go down.
  _           Drop the EOF character from the stack and go left.
%9   +9       Mod the total with 9, and add 9.
   @.         Output the result and exit.
```
Essentially we are calculating the sum of all digits, plus 45 per digit (which will ultimately be cancelled out when we mod with 9). This sum is subtracted from 3 (our starting total), and an additional 39 is subtracted by the missing digit (ASCII `*` minus three). Again that 3 minus 39 is a multiple of 9, so it's cancelled out when we mod with 9.
So in the end we're calculating the negative sum of all the digits, mod 9, plus 9, i.e.
```
9 - (digitsum % 9)
```
And that's gives us the missing digit.
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 50 bytes
```
+>,[---[<-[<<]>[<+++++++++<]>>-],]-[<+>-----]<---.
```
[Try it online!](https://tio.run/##SypKzMxLK03O/v9f204nWldXN9oGiGxi7aJttGEAyLPTjdWJBUpo2@mCQKwNkND7/9/QyNgKAA "brainfuck – Try It Online")
Prints a 9 for either 0 or 9. Missing character is represented by :
### How It Works
```
Tape Format:
    0 Total Input 0
The total is represented as 9-digitSum%9
+>,[ Start loop with 1 as the total
    --- Subtract 3 from the inputted byte to make the value%9 equal to the digit
    [   While the input byte exists
      <-                 Decrement the total
      [<<]>[<+++++++++<] If the total is 0, reset it to 9
      >>-                Decrement the input byte
    ]
,] Continue loop until there is no input
-[<+>-----]<---. Add 48 to the total to convert the digit to the ascii value and output it
```
The missing character needs to be a character that has a mod 9 of 4, +3 because we subtract 3 from the normal digits and +1 for the initialisation of the total as 1.
As a side note, there is a *lot* of inefficiency in the code for the sake of golfing, as each digit will reset the total 5 times each, rather than just once sometimes if I subtracted 48 instead of 3.
[Answer]
# [Befunge-98 (PyFunge)](https://pythonhosted.org/PyFunge/), 8 bytes
```
#q~3--9%
```
[Try it online!](https://tio.run/##S0pNK81LT9W1tNAtqAQz//9XLqwz1tW1VP3/39DIuAIA "Befunge-98 (PyFunge) – Try It Online")
Outputs via exit code. As with [Mistah Figgin's answer](https://codegolf.stackexchange.com/a/151583/76162), it only works with Pyfunge, where a negative number mod 9 becomes positive. Uses an x as the missing digit.
[Answer]
# Java 8, ~~36~~ 34 bytes
```
s->9-s.map(c->c>57?0:c-48).sum()%9
```
Returns `9` when both `0` and `9` are valid.
**Explanation:**
[Try it online.](https://tio.run/##jY5Na8MwDIbv/RWiMLAPNu7HWL2y5LxDe@mx7KC53uYsdkKkFMrIb8@8dKfBoGCBJT0Peis8o2pan6rT5@hqJIIdhvQ1AwiJffeGzsP@p50G4ESVDd1zqDVx5zHq58SH6QcktxkccuVHjBwc7CHBE4ykCqtIR2yFU4Ur7h9K8@jUeiM19VHIOztur17bv9bZ@9XPTThBzIlEvhHS@/EF5TXN4ULso2561m3ecJ1E0k7MF8tVOdfuAzsSUk6J/odLa@3tsDHL1c20MaZc/KGH2TB@Aw)
```
s->                               // Method with IntStream parameter and int return-type
   9-                             //  Return 9, minus:
     s.map(c->c>57?0:c-48).sum()  //   The sum of the digits (ignoring the question mark)
     %9                           //   modulo-9
```
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 7 bytes
```
19βN9%‹
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=19%CE%B2N9%25%E2%80%B9&inputs=%3F0023&header=&footer=)
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 40 bytes
```
param($a)0..9|?{!(($a-replace'x',$_)%9)}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/vyCxKDFXQyVR00BPz7LGvlpRA8jRLUotyElMTlWvUNdRiddUtdSs/f//v7qBgUGFoToA "PowerShell – Try It Online") or [Verify all test cases](https://tio.run/##FcrRCsIgFIDh@57ChkOlNs62q3NTDxIxZGgFbhNXJDif/WRXHz/8fv2asD2Nc2Q/y/R@rQuzibwOepZcK2hb3K/pKEs0wXinJyOiOPNR1agy5QPX4bHd4L7XqeIjay6sOknLypCJRNcP5RYREf8A9EMRAGInfg "PowerShell – Try It Online")
Takes input like `'123x'` into `$a`. Constructs a range `0` to `9` and uses `Where-Object` (here abbreviated as `|?`) to pull out those integers that match the clause. The clause takes `$a`, performs a regex `-replace` to replace the `x` with the current digit `$_` and gets the mod 9 with `%9`. Thus if 9 evenly divides, this will be zero. We take the Boolean-not thereof, which turns the zeros truthy and everything else falsey, so that satisfies the Where-Object clause. Those result(s) are left on the pipeline and output is implicit.
[Answer]
# [Haskell](https://www.haskell.org/), 35 bytes
```
f s=9-sum[read[i]|i<-s,i<':']`mod`9
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P02h2NZSt7g0N7ooNTElOjO2JtNGt1gn00bdSj02ITc/JcHyf25iZp6CrUJBUWZeiYKKQpqCkr2lpaXSfwA "Haskell – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~35~~ ~~34~~ 25 bytes
If the `?` can be `0 or 9`, the result is shown as `9`.
```
.
$*
1{9}
^
9$*;
+`;1
.
```
[**Try it online**](https://tio.run/##K0otycxL/K@q4Z7wX49LRYvLsNqylosrjstSRcuaSzvB2pCLS@//f0MjY3sue0tLSy57AwMjYy4DAwN7QwA)
### Explanation
```
.       Sum of the digits in unary + 1
$*
1{9}    Modulo 9
^       Prepend 9 semicolons, for subtracting
9$*;
+`;1    Subtract from 9
.       Back to decimal
```
[Answer]
# [Perl 5](https://www.perl.org/), 23 bytes
```
$_=- s/\D//r%9;s/0/0|9/
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZXoVg/xkVfv0jV0rpY30DfoMZS//9/A3sDAyPjf/kFJZn5ecX/dQsA "Perl 5 – Try It Online")
Doesn't care what character signifies the missing digit as long as it isn't a digit.
[Answer]
# Tcl, 53 bytes
```
puts [expr 9-([regsub -all (\\d)\\D? 0$argv +\\1])%9]
```
As with other answers, this is made shorter by not explicitly saying “0 or 9”.  
Instead, a result of “9” means either 0 or 9.
[Try it online!](https://tio.run/##K0nO@f@/oLSkWCE6taKgSMFSVyO6KDW9uDRJQTcxJ0dBIyYmRTMmxsVewUAlsSi9TEE7JsYwVlPVMvb///@GRsb2AA)
**Explanation**
It works pretty simply. It employs a regular expression to:
* split the argument into individual digits
* eliminate any ~~question mark(s)~~ non-digit(s)
* interleave the digits with plus signs
It then evaluates 9 - (sum\_of\_digits mod 9) to arrive at a final value in 1..9, which it then `puts`.
The leading 0 (in `0$argv`) is required just in case the question mark comes first in the input; a leading plus sign in the transformed sequence is not a problem for `expr`.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 8 bytes
```
%_iz19 9
```
[Try it online!](https://tio.run/##K6gsyfj/XzU@s8rQUsHy/39PAwMjYwA "Pyth – Try It Online")
Uses `I` instead of `?`.
* Convert to base 19.
* Negate.
* Modulo 9.
]