Original Post
I need help devising a counting algorithm using the following rules: I have a string where each character comes lexicographically after the last, ie if the first letter is 'a', then the next letter MUST be between 'b' and 'z'. So some valid words would be: abc abd bcd bdz wxy And invalid words would be: aaa aab zab zy ca Then I want to find its integer value, where it counts up. ie: a = 1 b = 2 ... z = 26 ab = 27 ac = 28 ad = 29 ... az = 51 bc = 52 bd = 53 be = 54 Note that ab = 27 (there is no aa = 27, because aa would be an invalid word, and so bc = 52 after az, because there is no ba, or bb) I'm looking for an algorithm that can determine the numeric value of a valid word based on that counting algorithm.