# Given a bit string $x$ of length $n$, how many strings are there that differ from $x$ in exactly $k$ positions?

Given a bit string $$x$$ of length $$n$$, how many strings are there that differ from $$x$$ in exactly $$k$$ positions?

Also, if we replaced the case with decimal strings, how would it change?

I'm a bit stuck. I'm not sure which method to use to solve this question. I'm between whether to use regular permutation, or difference method, but both of those could still be incorrect.

Any insight would be helpful, thank you!

• Your question should be clear without the title. After the title has drawn someone's attention to the question by giving a good description, its purpose is done. The title is not the first sentence of your question, so make sure that the question body does not rely on specific information in the title. – Martin R Jul 20 '19 at 16:09
• How many ways can you choose $k$ positions from the available $n$ positions? – AgentS Jul 20 '19 at 16:16
• Think of it like choosing $k$ positions to flip the bits – AgentS Jul 20 '19 at 16:18

Given a bit string of length $$n$$, how many strings are there that differ from $$x$$ in exactly $$k$$ positions.

Strategy:

1. Choose which $$k$$ of the $$n$$ positions differ from the original bit string.
2. In each place where the original bit string had a $$0$$, it must be replaced by a $$1$$; in each place where the original bit string had a $$1$$, it must be replaced by a $$0$$.

Given a decimal string of length $$n$$, how many strings are there that differ from $$x$$ in exactly $$k$$ positions.

Strategy:

1. Choose which $$k$$ of the $$n$$ positions differ from the original decimal string.
2. Choose which of the other nine decimal digits replaces the number in each of the $$k$$ positions where the new string differs from the original string.