# Conceptual question on pattern recognition

I am just a beginner in machine learning and finding tough time to understand few concepts. I have 10 strings of characters of length 50 each. These are the training data $T(i)$ for $i=1:10$. The first 5 come from class $A$ and next 5 from class $B$. Then there is an incoming string\test Test of same length. I calculate the number of common characters between each $T(I)$ and Test. Let this be a distance measure $dist(T(i),Test)$. Test will belong to or match a $T(i)$ if the number is maximum i.e Test $\epsilon$ max $dist(T(i),Test)$

• Can this distance count serve as a feature for recognizing task maybe feeding this distance into a Bayes classifier or k-nn?
• How can I apply clustering or classification for this kind such that I may know the incoming string is most similar to the training string and assign it to that class?

I know it is vague or maybe inappropriate but can somebody explain with a code how to do this and if it is valid to do so?