Skip to content

Instantly share code, notes, and snippets.

@Higgcz
Last active December 31, 2015 04:39
Show Gist options
  • Save Higgcz/7935140 to your computer and use it in GitHub Desktop.
Save Higgcz/7935140 to your computer and use it in GitHub Desktop.
Count number of different letters in word in array.
inline unsigned calcStates () {
unsigned numStates = (unsigned) substrings[0].size() + 1;
Word str1, str2;
for ( vector<Word>::iterator str = substrings.begin(); (str+1) != substrings.end(); ) {
str1 = *str;
str2 = *(++str);
unsigned i = 0;
while (str1[i] == str2[i] && i < str1.size()) i++;
numStates += (unsigned) str2.size() - i;
}
return numStates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment