# q-ary code/Latin squares

For any value of $q$ the largest number of elements in any q-ary code $C$ of length $4$, distance $3$ is $q^2$. How can we prove that this is attainable iff there are a pair of mutually orthogonal latin squares of order $q$?

Please show the full proof if you can. I am looking for the proof in order to proceed with my study of the subject. This is not to say I have not attempted to approach the problem- I just haven't the slightest idea how to.