Possible binaries sum This challenge is inspired by the AoC 2020, Day 14 - Part II, created by Eric Wastl and his team, which asks to output the possible binary values from a bitmask.
Let's say we've a bitmask like &quot;10X0X0&quot;, 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 [&quot;100000&quot;, &quot;100010&quot;, &quot;101000&quot;, &quot;101010&quot;].
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: &quot;X&quot;
[&quot;0&quot;, &quot;1&quot;]
[0, 1]
OUTPUT: 1

INPUT: &quot;0&quot;
OUTPUT: 0

INPUT: &quot;1&quot;
OUTPUT: 1

INPUT: &quot;1X0&quot;
[&quot;100&quot;, &quot;110&quot;]
[4, 6]
OUTPUT: 10

INPUT: &quot;1X0X1&quot;
[&quot;10001&quot;, &quot;10011&quot;, &quot;11001&quot;, &quot;11011&quot;]
[17, 19, 25, 27]
OUTPUT: 88

INPUT: &quot;X0X0X0X&quot;
[&quot;0000000&quot;, &quot;0000001&quot;, &quot;0000100&quot;, &quot;0000101&quot;, &quot;0010000&quot;, &quot;0010001&quot;, &quot;0010100&quot;, &quot;0010101&quot;, 
&quot;1000000&quot;, &quot;1000001&quot;, &quot;1000100&quot;, &quot;1000101&quot;, &quot;1010000&quot;, &quot;1010001&quot;, &quot;1010100&quot;, &quot;1010101&quot;]
[0, 1, 4, 5, 16, 17, 20, 21, 64, 65, 68, 69, 80, 81, 84, 85]
OUTPUT: 680

INPUT: &quot;1X1X1X1X1X1X1X1X1X1X1&quot;
OUTPUT: 1789569024

INPUT: &quot;1X01X01X01X01X01X01X01X01X01X01X01X0&quot;
OUTPUT: 201053554790400

INPUT: &quot;X000X000X000X000X000X000X000X000X000X000X000X000&quot;
OUTPUT: 307445734561824768

INPUT: &quot;101&quot;
[&quot;101&quot;]
[5]
OUTPUT: 5

INPUT: &quot;XXX&quot;
[&quot;000&quot;, &quot;001&quot;, &quot;010&quot;, &quot;011&quot;, &quot;100&quot;, &quot;101&quot;, &quot;110&quot;, &quot;111&quot;]
[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, so fewest bytes will win!


Sandbox link.
Python 2, 61 bytes

k=n=0
for c in input():n=n*2+-ord(c)%3;k+=c&gt;&quot;1&quot;
print(n&lt;&lt;k)/2

Try it online!
Implements this algorithm:

Convert the input from binary, treating X as \$\frac{1}{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)&lt;&lt;s.count('_'))/2

Try it online!