Text this: A derivation of the optimal answer-copying index and some applications