[Question]
  [
This challenge is inspired by the AoC 2020, [Day 14 - Part II](https://adventofcode.com/2020/day/14#part2), created by [Eric Wastl](https://twitter.com/ericwastl) and [his team](https://adventofcode.com/2020/about), which asks to output the possible binary values from a bitmask.
Let's say we've a bitmask like `"10X0X0"`, then we've to find the possible binary values that can be generated by replacing an `X` with either `0` or `1`. Here I've taken `X`, but you could take anything except `0` and `1`, of course.
So, the possible binaries are `["100000", "100010", "101000", "101010"]`.  
When each of them are converted in decimal, then these are `[32, 34, 40, 42]` respectively.  
And, finally the sum is `148`.
# Test cases
```
INPUT: "X"
["0", "1"]
[0, 1]
OUTPUT: 1
INPUT: "0"
OUTPUT: 0
INPUT: "1"
OUTPUT: 1
INPUT: "1X0"
["100", "110"]
[4, 6]
OUTPUT: 10
INPUT: "1X0X1"
["10001", "10011", "11001", "11011"]
[17, 19, 25, 27]
OUTPUT: 88
INPUT: "X0X0X0X"
["0000000", "0000001", "0000100", "0000101", "0010000", "0010001", "0010100", "0010101", 
"1000000", "1000001", "1000100", "1000101", "1010000", "1010001", "1010100", "1010101"]
[0, 1, 4, 5, 16, 17, 20, 21, 64, 65, 68, 69, 80, 81, 84, 85]
OUTPUT: 680
INPUT: "1X1X1X1X1X1X1X1X1X1X1"
OUTPUT: 1789569024
INPUT: "1X01X01X01X01X01X01X01X01X01X01X01X0"
OUTPUT: 201053554790400
INPUT: "X000X000X000X000X000X000X000X000X000X000X000X000"
OUTPUT: 307445734561824768
INPUT: "101"
["101"]
[5]
OUTPUT: 5
INPUT: "XXX"
["000", "001", "010", "011", "100", "101", "110", "111"]
[0, 1, 2, 3, 4, 5, 6, 7]
OUTPUT: 28
```
# Rules
* It is guaranteed that \$ 0 \leq \text{count}(X) \leq 12 \$ and \$ 1 \leq \text{length(mask)} \leq 48 \$.
* Input can be either a string, or an array of chars (non-empty).
* I have chosen `X` in bitmask, however you can replace it with any other character of your choice.
* Output will be the sum of the binaries in decimal.
* This is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so fewest bytes will win!
---
[Sandbox link](https://codegolf.meta.stackexchange.com/a/20552/83605).
  
[Answer]
# [Python 2](https://docs.python.org/2/), 61 bytes
```
k=n=0
for c in input():n=n*2+-ord(c)%3;k+=c>"1"
print(n<<k)/2
```
[Try it online!](https://tio.run/##lYzNCsIwEITv@xRhQUisP0m91cbnyK3ENGJp3YZQqT59TcSjIDIzC7vsfOE5XUcql47CfdKDvZ1bW0U7N@8DF7vow2Cd52hwgw0KmK/d4Jmq/MM7RFx6TVrCZYzMsY7Yp1eRpnVZbMfYcidWh2NfaHdChRBiRxOnuu7FvlwywYAEBcrIHKMgjay0fVH@@WlQMmGMSSgp/8kL "Python 2 – Try It Online")
Implements this algorithm:
1. Convert the input from binary, treating X as \$\frac{1}{2}\$.
2. Double the result for each X in the input.
Why does this work? If X appears \$k\$ times in the input, we're adding up \$2^k\$ near-copies of its binary value. Among these near-copies, each X in any position appears as 0 half the time and 1 half the time for an average of \$\frac{1}{2}\$, so we can treat X as the digit \$\frac{1}{2}\$.
In the code, we actually convert `0,X,1` to doubled values `0,1,2`, then halve the result before doubling for `X`'s. And, we use `_` for `X`, since we're allowed to use a different character -- anything with the same ASCII code modulo 3 would work, such as the digit `2`.
**63 bytes**
```
lambda s:(reduce(lambda n,c:2*n+-ord(c)%3,s,0)<<s.count('_'))/2
```
[Try it online!](https://tio.run/##lYxBCsMgFET3niKborY21XQn6T1cFII1hghGRQ2hp7emdFkoZWY@/GF44Zln77oy3e7FyuUxyiZxFPW4Ko0@hSOKd0d3Ovs4IoUPV5IIxX2fWuVXlxEcIMaXrmyzsbphPETjcjOhKLfBuLBmhNuog5UVCQUk730RgAIGmKB7BAP17KrfF@2bnwaMVowQFUXpP3kB "Python 2 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~[56](https://codegolf.stackexchange.com/revisions/216384/1)~~ 55 bytes
```
n!(a:x)|a<'X'=(2*n+read[a])!x|m<-4*n=m!x+1!x
n!x=n
(0!)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P09RI9GqQrMm0UY9Qt1Ww0grT7soNTElOjFWU7GiJtdG10QrzzZXsULbULGCK0@xwjaPK81Ww0BR839uYmaebUFRZl6JSpqSYYSh0n8A "Haskell – Try It Online")
## Explanation
Start with a simple recursive algorithm to convert binary to an integer:
```
n!(a:x)=(2*n+read[a])!x
n!x=n
(0!)
```
From here we add an extra rule if we hit an `X` which just adds the results for the X being 0 and 1 together:
```
n!('X':x)=n!('0':x)+n!('1':x)
n!(a:x)=(2*n+read[a])!x
n!x=n
(0!)
```
We can unroll the applications in that:
```
n!('X':x)=(2*n)!x+(2*n+1)!x
n!(a:x)=(2*n+read[a])!x
n!x=n
(0!)
```
We can move a `2*n` over to the other side since `(!x)` is affine
```
n!('X':x)=(4*n)!x+1!x
n!(a:x)=(2*n+read[a])!x
n!x=n
(0!)
```
From here we combine the pattern matches to save bytes.
[Answer]
# JavaScript (ES6), 55 bytes
```
f=(s,g=d=>f(s.replace('X',d)))=>1/s?+('0b'+s):g(0)+g(1)
```
[Try it online!](https://tio.run/##pZExb4MwEIX3/AorC7Yg4Qw2NpVIJ4buHVhdMISKYIRJlX9PQe0ESKGqzyfLkr97T8@f6kvZvK@74dSaQo9jmWDrVUmRXEpsz73uGpVr7GSOVxBCkgv17auLHfhwXEteKgzErTAlY25aaxp9bkyFS3zMjoSgHcv3ET0sWNjPwpKl/9Cl2T7lmYUNONsjPsFSLuGJnespPsGR3JDeqI1Zs28hYx7FELAN/0/3PHMaEgAFHnLORAwM1naA7o2Rr4LIsr1sIA@H6Xi/1haZVqNeD/e@tUi1SHVdbx71TQ21aT2kLBquGtn7DelHrnXxc@96ndd2eoFMid7SND0JztY/A/CX/o0oBMEYFyHjEZUBE5EcvwE "JavaScript (Node.js) – Try It Online")
### Commented
```
f = (                   // f is a recursive function
  s,                    // taking the input string s
  g = d =>              // g is a helper function taking a digit d
    f(                  // and doing a recursive call to f
      s.replace('X', d) // with the first 'X' in s replaced with d
    )                   //
) =>                    //
  1 / s ?               // if s looks like a number (i.e. does not contain any 'X'):
    +('0b' + s)         //   convert it from binary to decimal
  :                     // else:
    g(0) +              //   invoke g a 1st time to replace the first 'X' with '0'
    g(1)                //   invoke g a 2nd time to replace the first 'X' with '1'
```
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 38
```
echo $[`eval echo +2\#${1//X/{0,1\}}`]
```
[Try it online!](https://tio.run/##S0oszvhfnpGZk6pQlJqYYq2Qks@loFCcWqKgq6ugEuQa4BP5PzU5I19BJTohtSwxRwHM0TaKUVapNtTXj9CvNtAxjKmtTYj9n5Kfl/o/gsuAy5DLMMIAhCMMuYAECAJ5WCBIDUEENMLAgBTMZWgAtDciggsA "Bash – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 47 bytes
```
1#.#.@(]`(_ I.@E.[)`[}"#.[:#:@i.@(**2&^)1#._&=)
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/DZX1lPUcNGITNOIVPPUcXPWiNROia5WU9aKtlK0cMoFSWlpGanGaQHXxaraa/zW5/Jz0FEjUhV@PEURLHEwxV2pyRr6CoYKtQppCPIRjAOYYQDgWFmCeoUI8UDxewRAiagQRjQdBqAnmFpamZpYGRiYQ9RUgxcTg/wA "J – Try It Online")
Not super happy with this one...
[Answer]
# [R](https://www.r-project.org/about.html), ~~156~~ ~~142~~ ~~78~~ ~~61~~ ~~56~~ ~~52~~ ~~51~~ 50 bytes
In the entry of the bitmask, `2` replaces `X`.
Thanks to [Giuseppe](https://tio.run/##JYzBasMwEETv@gpBMeymMtndY4j6HQVjg2xLjeJGEYoNhdJvdxUyh3kzMEzZ37aH16LDvehPFewetjSt8Z7Amdmm6eIKOMTfbPk0t6xG65pjwzTkprpa7LdPX@sFruc2d@MH9@@MytubW0v8gdHMRoYFVb2HqGPSdFrQd9cu9qa3E4RzW3wGrqt4FDR0CKge2w38QYaMf3sAFpL6@QwvED0hVa8qwixCxMS4/wM "R – Try It Online"), came a reduction in [unnecessary brackets in an earlier version](https://tio.run/##JY3RioMwEEXf8xWBRZgpEWfmsZj9jgWxEDXZprappAqFst/upvS@nHvhwsn71/bwWnS4Z/2jgt3DlsY13hM4M9k0nl0Gh/haLB8nNVhXVXBta6bTglVTesOEarZXn37XM1zaeumGb@5ReXtza45PGMxk5DSjigFmLCKIOibNxxl9d@lib3o7Qmjr7Bfgco2NoKFDQPXYbuAPIEWGjfztAVhIGNW7fED0hpR8pgizCBET4/4P "R – Try It Online") recreating the binary duplications.
However, a more condensed version can be found by realising that the sum is the sum of the inverse of the non-zero digits, times 2 to the power of the number of 2's, ie
                                        [![enter image description here](https://i.stack.imgur.com/tNR31.gif)](https://i.stack.imgur.com/tNR31.gif)
which actually happens to be [the solution earlier worked out](https://codegolf.stackexchange.com/a/216371/85958) by [xnor](https://codegolf.stackexchange.com/users/20260/xnor). With improvements [from Dominic](https://codegolf.stackexchange.com/users/95126/dominic-van-essen) achieving the same score as this earlier solution and more from [Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe)!
```
function(x)2^sum(a<-x>1)*rev(x/4^a)%*%2^(seq(x)-1)
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP0@jQtMorrg0VyPRRrfCzlBTqyi1TKNC3yQuUVNVS9UoTqM4tRCoRtdQ83@aRrKGoY6BjhEEa2pygUSMdMAQyoPIg1QYQkUMgGwDuCwcamr@BwA "R – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~14~~ 12 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Y1ÝI2¢ãδ.;CO
```
Uses `2` instead of `X`.
[Try it online.](https://tio.run/##yy9OTMpM/f8/0vDwXE@jQ4sOLz63Rc/a2f//f0MDIyAEAA)
**Explanation:**
```
 1Ý           # Push the list [0,1]
   I2¢        # Count the amount of 2s in the input-string
      ã       # Take the cartesian product of [0,1] with this count
       δ      # Map over each inner list of 0s and 1s:
Y       .;    #  Replace every 2 in the (implicit) input-string one by one with the 0s
              #  and 1s in the current list
          C   # Convert each binary string to a base-10 integer
           O  # Sum the list together
              # (after which the result is output implicitly)
```
---
Fun alternative that's unfortunately a byte longer (**13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)**):
```
TIgãʒøþ€ËP}CO
```
Uses `X`.
[Try it online.](https://tio.run/##yy9OTMpM/f8/xDP98OJTkw7vOLzvUdOaw90Btc7@//8bGkQAIQA)
**Explanation:**
```
T           # Push 10
 Ig         # Push the length of the input-string
   ã        # Take the cartesian product of "10" with this count
    ʒ       # Filter this list of binary strings by:
     ø      #  Zip/transpose it with the (implicit) input, creating pairs
      þ     #  Remove all "X" from each pair by only leaving digits
       €Ë   #  Check for each if all digits are the same
            #  (this checks if the 1s and 0s are at the same positions between the 
            #   current binary string and input; and since we've removed all "X" those
            #   single digits are truthy by default)
         P  #  Check if this is truthy for all of them with the product
    }C      # After the filter: convert any remaining binary string to a base-10 integer
      O     # Sum the list together
            # (after which the result is output implicitly)
```
[Answer]
# [Haskell](https://www.haskell.org/), 53 bytes
```
sum.foldl(%)[0]
l%c=[2*a+1-read[b]|a<-l,b<-"01",b/=c]
```
[Try it online!](https://tio.run/##lUzLCsIwELz7FSFY8NHo1nPzCd4DMYdt2mjppoZWb367sa@jIDKzM8wyzA37piKKTl5i//QHd6eSNslWg1lRYqU@7XCfia7CUhfmhbmgtMgFh4ynxVFaEz3WrfQYzix0dftgazYE5pjmiqeMwyjZJAoWU1MefMT8@4Kl/JNTD@ZJpeZlgH@Om/i2jvDaR2FD@AA "Haskell – Try It Online")
Implements the spec somewhat directly, using a modified from-binary conversion that works on lists of digits to produce lists of possible outcomes. Any character can be used for `X` except of course for `0` and `1`.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 11 bytes
```
*ΠfI¹ḋm?I\ε
```
[Try it online!](https://tio.run/##yygtzv7/X@vcgjTPQzsf7ujOtfeMObf1////0YY6RjpE4VgA "Husk – Try It Online")
Port of [xnor's approach](https://codegolf.stackexchange.com/a/216371/95126).
Input is list of binary digits (`0` or `1`), with `2` to represent the bitmask.  
[13 bytes](https://tio.run/##yygtzv7//9By/fxzC9I8H@7ozrX3jDm3NeX///@GRlggAA) to accept input as an integer instead of a list.
```
*               # multiply
 Π              # product of 
  fI¹           # non-zero elements of input
     ḋ          # by binary number with digits given by
      m         # mapping over all digits of input
       ?  ε     # if digit is equal to at most 1
        I       # leave it alone
         \      # otherwise take reciprocal
```
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 35 bytes
```
s/X/{0,1}/g;map$\+=oct"0b$_",glob}{
```
[Try it online!](https://tio.run/##K0gtyjH9/79YP0K/2kDHsFY/3To3sUAlRts2P7lEySBJJV5JJz0nP6m2@v//CAMw/JdfUJKZn1f8X9fXJ7O4xMoqtCQzx7a4NPe/bkEOAA "Perl 5 – Try It Online")
[Answer]
# [MATLAB](https://www.mathworks.com/products/matlab.html), 55 46 bytes
```
@(x)2.^(nnz(x):-1:1)*mod(x'*2,3)/4*2^nnz(x>49)
```
Inspired by [the Python solution of xnor](https://codegolf.stackexchange.com/a/216371/91877).
But here we don't use a loop, we work with array operators.
Thanks to [Luis Mendo](https://codegolf.stackexchange.com/users/36398/luis-mendo) for replacing the sum of element-wise products by the dot product (-5 bytes).
Instead of `X`, it expects `_` as input:
```
ans('1_0_1')
ans =
    88
```
etc.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 67 bytes
```
Distribute@StringReplace[#,"X"->"0"+"1"]/.s_String:>s~FromDigits~2&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73yWzuKQoM6m0JNUhGMjISw9KLchJTE6NVtZRilDStVMyUNJWMlSK1dcrjocosLIrrnMrys91yUzPLCmuM1L7HwAULolW1rVLc1COVasLTk7Mq6vmAmrX4QJqBxKGYCLCAEpFgPlAGgQhYlggVDFBBDHLwIAUDDbbAOKMiAglrtr/AA "Wolfram Language (Mathematica) – Try It Online")
-1,2,...50...61 bytes from @att
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), 37 bytes
```
{(*/(+/t)#2)*{y+2*x}/x-48+1.5*t:x=50}
```
[Try it online!](https://tio.run/##y9bNz/7/P82qWkNLX0Nbv0RT2UhTq7pS20irola/QtfEQttQz1SrxKrC1tSg9n@1RoW1QppChWatuoaSkZK1gpIBiDAEE0YGUMoIzAfSIAgRwwKhigkiiFkGBqRgsNkGEGcYGSlp/gcA "K (oK) – Try It Online")
Inspired by [xnor's Python solution](https://codegolf.stackexchange.com/a/216371/75681).
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), (9?) 12 bytes
9 if we may accept a list of integers (e.g. `"0X1X0"` as `[0,2,1,2,0]`) - remove the leading `V€µ`.
```
V€µẹ2ŒPṬạḂḄS
```
A monadic Link accepting a list of characters from `"012"` (`'2'` representing an unknown bit) which yields the sum.
**[Try it online!](https://tio.run/##y0rNyan8/z/sUdOaQ1sf7tppdHRSwMOdax7uWvhwR9PDHS3B////VzI0wgKVAA "Jelly – Try It Online")**
### How?
```
V€µẹ2ŒPṬạḂḄS - Link: list of characters, S    e.g. "022001"
V€           - convert (S) to a list of integers   [0,2,2,0,0,1]
  µ          - start a new monadic chain, f(A=that)
   ẹ2        - indices of 2                        [2,3]
     ŒP      - power-set                           [[],[2],[3],[2,3]]
       Ṭ     - un-truth                            [[],[0,1],[0,0,1],[0,1,1]]
         Ḃ   - mod-2 (A)                           [0,0,0,0,0,1]
        ạ    - absolute difference                 [[0,0,0,0,0,1],[0,1,0,0,0,1],[0,0,1,0,0,1],[0,1,1,0,0,1]]
          Ḅ  - convert from binary                 [1,17,9,25]
           S - sum                                 52
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 71 bytes
```
c,s;f(char*m){for(c=1,s=0;*m;88-*m++||(s++,c*=2))s+=s+=*m==49;c=c*s/2;}
```
[Try it online!](https://tio.run/##dY5NCoMwEIX3nkKEQn4UE1EbCbmHi25krFZoYjHtSj27lZqdKTOLGd775g0kPcD2MXbozb0Nn6Ppww1iKzsEj2YiGs/dOCFQPLaKSaKlEAnRlC4LspTGQFSGsaVqb6KVyisJCohNM7lug3mHuhlMiPAcvKZ97VB0aW8mivehjjCWacrPCjsUdlb4X4bXjuLMK9YOFcLzCfvVYSiF94CnXN5VVEVZsSz3YMyZCk9o7QIzEazbFw "C (gcc) – Try It Online")
* Saved 2 bytes thanks to @Ceilingcat
* Works only for small numbers (int)
added unsigned long in header to test 1X1X1X1X1X1X1X1X1X1X1
We iterate a char array:
`s` is sum  
`c` is number of masks, initially 1
```
s+=*m==49  - we add 1 if we have '1'
s*=2       - then we multiply by 2
88-*m++||  - if we have a 'X'
(s++,c*=2) - we add 1 and we double number of possible masks. 
c=c*s/2    - finally we multiply sum by c and divide by 2 because we multiplied sum one time more than needed.
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~27~~ 20 bytes
```
{_2/0.5^x,&+/^x:.'x}
```
[Try it online!](https://ngn.codeberg.page/k#eJyVU1FP2zAQfvevsKyJbVpo7pzYceJfsJdtDyBVqsooJYWI0rCmSEFo++27JDY2WyVEHMvnz+cvd/ddNtXzT5nCTF30ycmX9KKvZh/734wdqucPi6c/+2rDOe/tZXtnP11uVs3W9vbJ7j8vB59FIriwuBwtEBYmCx0mkBOI4G1OB8aMO9oMQ1ht/PGRQZcLUypdgsw9yZuvsBIQVKZUXpSQA7gPArxnCptBkeeqyHKl0ci80FPkCBSWmjg5JSAJZixlt4fDQ1el6bq9rm/a7WbWHVbru7pf3652N/Vs3d6nvx7r7tC0uy6VqDNdpg9t1zVX2/r0qtmt9k3dnXaP9yljX7/9OD+ruJgLtqC6JpxKumQLSDjV9fv52XiKwQ/ECwoBRXHMF+cwsCJMvAgDc55wHTHDK/c5uguU+XCFVnR3wRs4BogFRVgmXCqaRSA0JsoJxjFmNj0DxWShNzGg6FEMvhh8Mfii82VjrM4ZAzEGYgzEGIgRoiQx+E7EToCEU7EoP9Q0KV9JoCRUDzUkXBuaVANDuCHcEG5UqAU1fFzdIyOS7aX7Xwny5hsY/vkVYhkA3jMD5f//RRQcuF4ZyxVlraIvz734TrZxwWmHXilXed+j4xJpIBOeeSVIiKjXJIXD/gJO3gp4)
Modeled after [@Galen Ivanov's oK answer](https://codegolf.stackexchange.com/a/216428/98547). Uses `" "` in place of `"X"` in the input.
* `x:.'x` convert input string to a list of integer digits, updating variable `x` (spaces in the input become `(::)`s, i.e. null functions)
* `&+/^` generate n 0's, where n is the number of blanks in the input
* `x,` append these 0's to the end of the digit-ified input
* `0.5^` fill nulls with 0.5's
* `_2/` convert from base-2 and take the floor
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 20 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
år╢T>∩E%>►ΣD"╬@☼≡ ╫^
```
[Run and debug it](https://staxlang.xyz/#p=8672b6543eef45253e10e44422ce400ff020d75e&i=X%0A0%0A1%0A1X0%0A1X0X1%0AX0X0X0X%0A1X1X1X1X1X1X1X1X1X1X1%0A1X01X01X01X01X01X01X01X01X01X01X01X0%0AX000X000X000X000X000X000X000X000X000X000X000X000%0A101%0AXXX&a=1&m=2)
Shortened from 32 by borrowing the idea from Kevin Cruijssen's answer.
[Answer]
# [Octave](https://www.gnu.org/software/octave/), ~~66~~ 59 bytes
```
@(x)(t=0:2^nnz(x)-1)*all(abs(dec2bin(t)*2-mod(2*x,99))<2,2)
```
Uses character `b` instead of `X`. Runs out of memory for the two longest test cases.
[**Try it online!**](https://tio.run/##y08uSSxL/Z9mq6en999Bo0JTo8TWwMooLi@vCsjRNdTUSszJ0UhMKtZISU02SsrM0yjR1DLSzc1P0TDSqtCxtNTUtDHSMdL8n5ZflJtYopCTn5fOlaahnqSuCaIMIJQhlEoygDOSoGJAFgjCxLFAqJQBTEMSUPF/AA "Octave – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 43 bytes
```
d[c=0;d/@#/. 2:>++c^0/2,2]2^c&
d=FromDigits
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7PyU62dbAOkXfQVlfT8HIyk5bOznOQN9IxyjWKC5ZjSvF1q0oP9clMz2zpPh/QFFmXkm0sq5dmoNzRmJRYnJJalGxg3KsWl1wcmJeXTWXkpGSDpeSAYgwBBNGBlDKCMwH0iAIEcMCoYoJIohZBgakYLDZBhBnGBkpcdX@BwA "Wolfram Language (Mathematica) – Try It Online")
Input a list of characters. Uses `2` instead of `X`.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), ~~41~~ 29 bytes
```
+%1`X
0$'¶$`1
1
01
+`10
011
1
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wX1vVMCGCy0BF/dA2lQRDLkMuA0Mu7QRDAyAN5P3/D5QDChpGGIBwhCEXkABBLkOguoiICAA "Retina 0.8.2 – Try It Online") Link includes smaller test cases (code uses unary arithmetic so large numbers won't work on TIO). Explanation:
```
+%1`X
0$'¶$`1
```
Repeatedly replace each line containing an `X` with two copies of that line, one with a `0` and one with a `1` in place of the first `X`.
```
1
01
+`10
011
```
Convert each line from binary to unary.
```
1
```
Take the sum and convert to decimal.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 18 bytes
```
Ｉ÷×↨Ｅθ⌕0X1ι²Ｘ²№θX²
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwzOvxCWzLDMlVSMkMze1WMMpsThVwzexQKNQR8EtMy9FQ8kgwlBJRyFTU1NHwQiIA/LLU4s0jHQUnPNLgYYAlSlFKEEkNTWt//83jABq@K9blgMA "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Based on @xnor's algorithm.
```
     θ              Input string
    Ｅ               Map over characters
      ⌕             Find index of
          ι         Current character
       0X1          In literal string `0X1`
   ↨       ²        Convert from "binary"
  ×                 Multiply by
             ²      Literal `2`
            Ｘ       Raised to power
              №     Count of
                X   Literal string `X`
               θ    In input string
 ÷                  Integer divide by
                 ²  Literal `2`
Ｉ                   Cast to string
                    Implicitly print
```
[Answer]
# Scala, 61 bytes
```
_./:(Set(0)){(a,c)=>for(s<-a;d<-Set(c%2,c%3))yield s*2+d}.sum
```
[Try it online!](https://scastie.scala-lang.org/1UJUJrApT4mIcBYpBMOOtQ)
Turns out `X`'s value of 88 is perfect for this algorithm.
A simple binary-to-decimal conversion would look like this in Scala. `/:` is the fold operator. Starting with `0`, you multiply 0 by 2 and add the first digit. Then you multiply that by 2 again and add the next digit, and so on.
```
(0 /: listOfInts)((a, c) => 2 * a + c)
```
This is very similar, except now we're folding with multiple integers, and we're taking the sum at the end. In the lambda used for folding, `a` is all the accumulated sums, and `c` is the next character. For every sum `s` in `a` (`for(s<-a`), for every possible digit `d` that `c` could represent `d<-Set(c%2,c%3)`, we do the same thing as above - double the accumulator and add the next digit (`d`) to it, doubling the size of our set of accumulators each time.
`Set(c%2,c%3)` works because `'0'%2` and `'0'%3` both return `0` and `'1'%2` and `'1'%3` both return `1`. Even though there's two of them, since we're using a `Set`, the duplicate is automatically removed. If, however, `c` is `'X'` (88), then `'X'%2` is `0` and `'X'%3` is `1`, giving us two different possible values, which is pretty nice.
[Answer]
# [Icon](https://github.com/gtownsend/icon), ~~85~~ 77 bytes
```
procedure f(s)
b:=n:=0
c:=!s&{c=2&{c:=.5;n+:=1};b:=2*b+c}&\z
return b*2^n
end
```
[Try it online!](https://tio.run/##lVDbCsIwDH3vV8Q9jFandAVBKvVHvIDr4ixoJ12nqPjt2nU@@CCIOckJCYdDiNG1fT5PrtZYtg5hRxtGCqmsVJxoqQZNetdKBJJqMp3bkVT5Yx4EYliM9CNd3YhD3zoLxVBsLEFbfrgdt8ZSRiAEntFdoQmOy0QkGSS8ozyS4O8m4hx6h373BW/xz@y9OP@nojfvzxAiWUNZQ7w/BL0445EecOdpk8GUs6AaLyCInan2nhrrsUJHuyeyLJ8xxuJDXg "Icon – Try It Online")
Uses `2` instead of `X`.
Inspired by [xnor's Python solution](https://codegolf.stackexchange.com/a/216371/75681).
[Answer]
# [Factor](https://factorcode.org/), 46 bytes
```
[ [ 48 - >bin ] map [ bin> ] product-map sum ]
```
[Try it online!](https://tio.run/##bU6xCoMwFNzzFYe7YkOHYsG1uLiUTuKQpilKa4wvcZDSb09jLJ3Kwb1797jj3YV0I/nLuapPBR6KtHpiEK7LjCCrCIaUc4uhXjtYNc1KS2XZT2WGxtssHQSRWGyM4siquoCVJJzs2IsBSZ6svIvMOd9mHrFd@B8k7M0alLEabeg2vkGD/QEpymuvNy84QZdh@f6SrqadB7R@VZn/AA "Factor – Try It Online")
Takes an array of charcodes (the character `2` is used for X) and returns the sum. Uses the built-in that generates the Cartesian product of multiple sequences. (I think it's already done in many answers.)
```
[
  [ 48 - >bin ] map     ! map '0', '1', '2' to "0", "1", "10" respectively
  [ bin> ] product-map  ! compute cartesian product of all strings,
                        ! and convert from binary to integer
  sum                   ! sum
]
```
[Answer]
# [J](http://jsoftware.com/), 21 bytes
```
1#.2#.[:>@,@{#:@".&.>
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/DZX1jJT1oq3sHHQcqpWtHJT01PTs/mtycaUmZ@QrGCrYKqQpqBupQ7gGEK4BlGthAeEbGhkYGULFjKBiRkYwTYbmFpamZpYGRiYw1Vig@n8A "J – Try It Online")
Exact same algorithm as [my Factor answer](https://codegolf.stackexchange.com/a/216552/78410). Takes a string, with `2` in the place of X. If a plain integer vector is allowed, remove `@".` to get 18 bytes.
```
1#.2#.[:>@,@{#:@".&.>
                  &.>  NB. Apply to each character and enclose...
             #:@".     NB. Eval and convert to binary (0 -> 0, 1 -> 1, 2 -> 1 0)
           @{  NB. Take cartesian product of all boxed vectors
         @,    NB. Remove unnecessary outer array shape
      [:>      NB. Unbox the result vectors
   2#.         NB. Convert from binary to integer for each row
1#.            NB. Sum
```
]