Skip to content

Instantly share code, notes, and snippets.

@romgerman
Last active April 24, 2019 17:37
Show Gist options
  • Select an option

  • Save romgerman/db5cea16954f67b1ff41f7e887cd1e34 to your computer and use it in GitHub Desktop.

Select an option

Save romgerman/db5cea16954f67b1ff41f7e887cd1e34 to your computer and use it in GitHub Desktop.
Incremental name generator
a b c d e f g h i j k
l m n o p q r s t u
v w x y z A B C D E
F G H I J K L M N O
P Q R S T U V W X Y
Z _ aa ab ac ad ae af ag ah
ai aj ak al am an ao ap aq ar
as at au av aw ax ay az aA aB
aC aD aE aF aG aH aI aJ aK aL
aM aN aO aP aQ aR aS aT aU aV
aW aX aY aZ a_ ba bb bc bd be
bf bg bh bi bj bk bl bm bn bo
bp bq br bs bt bu bv bw bx by
bz bA bB bC bD bE bF bG bH bI
bJ bK bL bM bN bO bP bQ bR bS
bT bU bV bW bX bY bZ b_ ca cb
cc cd ce cf cg ch ci cj ck cl
cm cn co cp cq cr cs ct cu cv
cw cx cy cz cA cB cC cD cE cF
cG cH cI cJ cK cL cM cN cO cP
cQ cR cS cT cU cV cW cX cY cZ
c_ da db dc dd de df dg dh di
dj dk dl dm dn do dp dq dr ds
dt du dv dw dx dy dz dA dB dC
dD dE dF dG dH dI dJ dK dL dM
dN dO dP dQ dR dS dT dU dV dW
dX dY dZ d_ ea eb ec ed ee ef
eg eh ei ej ek el em en eo ep
eq er es et eu ev ew ex ey ez
eA eB eC eD eE eF eG eH eI eJ
eK eL eM eN eO eP eQ eR eS eT
eU eV eW eX eY eZ e_ fa fb fc
fd fe ff fg fh fi fj fk fl fm
fn fo fp fq fr fs ft fu fv fw
fx fy fz fA fB fC fD fE fF fG
fH fI fJ fK fL fM fN fO fP fQ
fR fS fT fU fV fW fX fY fZ f_
ga gb gc gd ge gf gg gh gi gj
gk gl gm gn go gp gq gr gs gt
gu gv gw gx gy gz gA gB gC gD
gE gF gG gH gI gJ gK gL gM gN
gO gP gQ gR gS gT gU gV gW gX
gY gZ g_ ha hb hc hd he hf hg
hh hi hj hk hl hm hn ho hp hq
hr hs ht hu hv hw hx hy hz hA
hB hC hD hE hF hG hH hI hJ hK
hL hM hN hO hP hQ hR hS hT hU
hV hW hX hY hZ h_ ia ib ic id
ie if ig ih ii ij ik il im in
io ip iq ir is it iu iv iw
class NameGenerator
{
char[] allowedChars = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'_' };
int index = 1;
public string New()
{
var len = allowedChars.Length;
var result = string.Empty;
var n = index;
while (n > 0)
{
var letter = n % len;
if (letter == 0)
letter = len;
result = allowedChars[letter - 1] + result;
n = (n - 1) / len;
}
index++;
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment