dio.la

Dani Guardiola’s blog

Jan 1, 1970January 1st, 1970 · 1 minute read · tweet

The unexpected complexity of list letter markers

Using math to solve the x, y, z, aa, ab, ac... problem.

All indexes are zero-based.

  • xx = input index.
  • ss = size of the collection of available symbols (e.g. a, b, c, ..., z).
  • pp = digit position from the right.
  • yy = index of the symbol in the collection.

For the domain: {xWxo}\set{x \in \mathbb{W} | x \geq o},

we can describe the algorithm with the function:

f(x,s,p)=xospmodsf(x,s,p)=\lfloor \frac{x-o}{s^p} \rfloor \mod s,

where: o=n=0psn1o=\sum_{n=0}^p s^{n}-1.

oo is the "digit offset", which compensates for two things:

  • Zero-based input index (1-1).
  • Leading undefined values (n=0psn\sum_{n=0}^p s^{n}).

Keep up with my stuff. Zero spam.

You're looking at my drafts!

Visit the main site: dio.la