3
$\begingroup$

Suppose I have an alphabet (e.g. consisting of ABCDEF) and a lexicographic order is defined i.e.

A -> B ... -> F -> AA -> AB .. -> AF -> BA -> BB -> ... -> BF ... -> FF -> AAA -> ...

Is there a way to check, what the N-th word in the above sequence is? For instance, the first work is "A", the 7th is "AA".

3 Answers 3

6

It just looks like a numbering system with base 6 instead of 10. So I would just use the normal equation for changing bases.

Like $A=0, B=1, C=2, D=3, E=4, F=5$, and use the normal formula to switch the number between decimal system and system based on 6.


Actually, it looks a bit more complicated than that since there is no "zero" in this system. Define $S_n = \sum_{i=0}^n 6^n$. Given any $N$, let $j$ be the largest integer such that $S_j \leq N$. Let $N_0 = N - S_j$.

Now change $N_0$ into base 6, and fill the digits so that you get $j+1$ many digits. Then switch back to the alphabet system.

For instance, if you want to find 51st word, you would notice that $43 = S_2 < 51$, so $N_0 = 51-43 = 8$. $8$ in base 6 is $12$, so fill the zeroes in front to get $012$. Finally, the word you were looking for would be $ABC$.

  • 0
    Okay, now it all makes sense! Thanks a lot..2012-09-14
0

This is the same question as "How to change a number in decimal system to senary system?". Assume N=a1*6+a2*6^2+a2*6^3+...+ai*6^i(a1,a2,...,ai in {0,1,2,3,4,5}). The jth letter in the word belongs to aj(A if aj=1, B if aj=2 and so on).

  • 0
    You are r$i$ght. aviness answer the question exactly.2012-09-14
0

Since you have six alphabets here, you are going to have to convert the n (term which you want to find, into a base 6 number).

For example if you want to find the 17th character in that sequence you will have to write something like (17) in base 10 = (25) in base 6.

You then assign each alphabet a number so you will have A = 1. B = 2. C = 3. D = 4. E = 5. F = 6.

Hence the number 25 in base six is BE. So BE is the 17th number in the sequence.