Asymptotically Sharp Length Thresholds for \texorpdfstring{$q$}{q}-ary Codes with Distances \texorpdfstring{$2$}{2} and \texorpdfstring{$4$}{4}
For an integer $q\ge5$, let $A_q(n,\{2,4\})$ be the largest cardinality of a subset of a $q$-ary Hamming space of length $n$ in which every two distinct words have distance $2$ or $4$. Set \[ N(q)=\left\lceil\max\left\{2q+1, \frac{17+\sqrt{8q^2+96q-95}}2\right\}\right\rceil. \] We prove that $A_q(n,\{2,4\})=1+\binom n2...