Calculating the probability of an event over multiple subset I'm struggling on the following problem:

You are given N boxes indexed from 1 to N.  Each box contains either
no coins or one coin.  The number of empty boxes and the number of
boxes with one coin are denoted by n0 and n1, respectively.  You take
a random subset of the boxes where each subset has the same same
probability to be selected.  The empty set and the set itself are
considered a subset.
Given n0 and n1, what is the probability that the total number of
coins in the random subset is even?
Constraint: N = n0 + n1 < 100000
EXAMPLES
1

*

*Input: n0 = 1, n1 = 0

*Output: 1.0

*Explanation: There are two subsets: [] and [0]. Both of them have an even sum.

2

*

*Input: n0 = 0, n1 = 2

*Output: 0.5

*Explanation: There are four subsets: [], [1], [1], and [1, 1]. The sum of [] and [1,1] is even.


So far I attempted an implementation in Python 3.8, but I think it works ok, but it takes very long to compute for larger numbers.
prob = 0

n0 = 1
n1 = 4

for j in range(0, n1+1):
        if (j % 2 == 0):
            prob += comb(n1, j)

total_prob = (2**n0 * prob) / (2 ** (n0+n1))
total_prob

 A: If $n_1=0$ then the answer is $1$ because all choices have no coins (and $0$ is even).
For $n_1>0$ the answer is $\frac 12$.
Proof:
First note that, if $n_1$ is odd, the answer is $\frac 12$ because either the chosen set or its complement (but not both), have evenly many coins.
Now suppose that $n_1$ is even.
Choose a coin $C$. We divide the subsets into two types, according to whether $C$ is an element or not. Of course there are $2^{N-1}$ subsets of each type.
If you choose  from the subsets without $C$ then we are in the odd case, as we are, effectively, choosing a subset from $n$ boxes that contain $n_1-1$ coins,  and we are done.
If you choose from the subsets with $C$ then the problem reduces to the case of $n_1-1$ coins as we are choosing a subset of the $n-1$ boxes which collectively hold $n_1-1$ coins.  As $n_1-1$ is odd, we are done.
A: Here is another proof that if $n_1 >0$, then the number of subsets containing an even number of coins is the same as the number of subsets containing an odd number of coins.
Let's say $N_{even}$ is the number of subsets containing an even number of coins, and $N_{odd}$ is the number containing an odd number of coins.
How many subsets are there that contain exactly $k$ coins, where $0 \le k \le n_1$?  There are $\binom{n_1}{k}$ ways to select the boxes containing coins, and then we can throw in any subset of the empty boxes, which can be done in $2^{n_0}$ ways.  So all together, there are
$$\binom{n_1}{k}2^{n_0}$$
subsets that contain exactly $k$ coins.
So
$$\begin{align} N_{even}-N_{odd} &= \sum_{k \text{ even}} \binom{n_1}{k}2^{n_0} - \sum_{k \text{ odd}} \binom{n_1}{k}2^{n_0} \\
&= \sum_{k=0}^{n_1} (-1)^k \binom{n_1}{k}2^{n_0} \\
&= 2^{n_0} \sum_{k=0}^{n_1} (-1)^k \binom{n_1}{k}
\end{align}$$
But
$$\sum_{k=0}^{n_1} (-1)^k \binom{n_1}{k} = 0$$
because by the Binomial Theorem,
$$0 = (1-1)^{n_1} = \sum_{k=0}^{n_1} (-1)^k \binom{n_1}{k}$$
so
$$ N_{even}-N_{odd} = 0$$
