The question is — How many functions are there from the set ${1,2,...,n}$, where $n$ is a positive integer, to the set ${{0,1}}$ that assign $1$ to exactly one of the positive integers less than $n$?
I have done this — there are $(n-1)$ elements in the domain that are less than $n$. So we have $(n-1)$ choices to which $1$ can be assigned. Once that is done, every other element in the domain is mapped to $0$. So I think the answer is just $(n-1)$. This is wrong, it should be $2(n-1)$, but I do not understand where the $2$ is coming from.
00010as well as00011as being valid. You counted only where $n$ mapped to zero. There are just as many where $n$ was mapped to $1$ as well, hence the factor of two. – JMoravitz Dec 18 '20 at 16:16