I'm trying to figure out how to do some substitutions in word strings, so that the pattern of repeated letters will be revealed. For example, these words:
dog
cat
man
would all have the same pattern "123", since no letters are repeated. But the words:
add
bee
would both have the pattern "122", since their second letter is repeated in the third position. Similarly, the words gag and eye would both have the pattern "121", since the first letter is repeated in the third position. The words away and baby would have the pattern "1214", and so on.
I've been trying for hours to figure out how to do this. I'm sure seeing a professional solution would teach me some very interesting things about Swift!