How do I calculate MDS codes?
It seems you are looking after (linear) MDS codes. A linear $[n,k,d]$-MDS code  "partitions" the space into $2^k$ balls of size $2^n/2^k$ elements each, so that the minimal distance between any two codewords is at least $d=n-k+1$. This is the maximal possible distance by the singleton bound.

Now, Let $C$ be such a code, and consider its cosets, that is, given any word $w\in \{0,1\}^n$ look at the affine subspace $w+C = \{ w+u \mid u\in C\}$. It is not difficult to see that any such coset is also an MDS code (namely, it partitions the entire space into balls of the same size, with the same distance guarantees; however it are no longer a linear space, but an affine one).

To answer your question, given any $\alpha\in \{0,1\}^n$ and any coset $\beta = w+C$, $\alpha$ is within distance $\lceil d/2\rceil$ from one word in $w+C$ (the center of the appropriate ball where $\alpha$ lies). Due to the singleton bound, such a distance is optimal.