Prove one-to-one function Let $S$ be the set of all strings of $0$'s and $1$'s, and define $D:S \rightarrow \mathbb{Z}$ as follows: For all $s\in S$,
$D(s)= \text{the number of}\,\, 1$'s in $s$ minus the number of $0$'s in $s$. 
a. Is $D$ one-to-one(injective)? Prove or give counterexample if it is false.
b. Is $D$ onto(surjective)? Prove or give a counterexample. 
a. I know $D(S1)\neq D(S2)$ and $S1=S2$. Since $11000\neq 10100$ but $D(11000)=-1$ and $D(10100)=-1$. So does that means that D is not one-to-one? 
b. ?

a) Yes, the function is indeed not injective, and your idea is correct! 
b) You have to show that, given an arbitrary integer $n$, then you can find a string $S$ such that $D(S)=n$. For example, if $n=3$, then take $S=111$...
