Probability of dot product of two vectors being odd. This was a question which was asked in an exam yesterday, and I am typing this from my memory. So I apologise in advance in case there is any error.

Consider that $a$ is a non-zero vector, such that $a \in \{0,1\}^n$, and $b$ is a vector which is chosen uniformly and randomly from $\{0,1\}^n$.
What is the probability that $\Sigma_{i=1}^{n}a_i \, b_i$ is odd?

My attempt was as follows:
When choosing $b$, the total possible cases can be $2^n$. For selecting the favourable ones, if the sum of products till the $n-1^{th}$ term is odd, the last element of $b$ will be zero and if it is even, we can split it into two cases - if the last element of $a$ is zero, then we cannot choose any value of $b$ and if the last element of $a$ is one, then we can choose the last element of $b$ as one to get an odd sum. But post this, I haven't been able to conclude what should be the final answer.
Is this line of thinking correct? 
Thank you.
 A: Hint: Let $\mathcal E$ denote the set of vectors $b$ that yield an even dot-product, and let $\mathcal O$ denote the set of vectors that yield an odd dot-product.  I claim that there is an invertible (so injective and surjective) function $f:\mathcal E \to \mathcal O$.
Alternatively, we can produce an invertible function $f:\{0,1\}^n \to \{0,1\}^n$ such that $f(b) \in \mathcal O \iff b \in \mathcal E$.

Another approach: note that if $a_i = 0$, then changing $b_i$ doesn't affect the resulting dot-product.
So, we could count the number of $b$ that produce an odd sum as follows: let $i_1,\dots,i_k$ be the indices such that $a_{i_1} = \cdots = a_{i_k} = 1$ and the rest of $a$'s entries are zero.  We can uniquely construct every vector $b$ with an odd sum as follows:


*

*Select the $n-k$ entries of $b$ that don't matter ($2^{n-k}$ possibilities)

*Select a vector $(b_{i_1},\dots,b_{i_k})$ for which $\sum_{j=1}^k b_{i_j}$ is odd.


It suffices to count how many choices there are for this second case.  In other words, it suffices to consider the smaller problem in which $a = (1,\dots,1)$.
