15 lines
322 B
Plaintext
15 lines
322 B
Plaintext
to_key = function(n)
|
|
-- represent an integer n in base-26 using a-z
|
|
local result = {}
|
|
n = math.floor(n)
|
|
local a = string.byte('a')
|
|
while n > 0 do
|
|
local digit = n % 26
|
|
table.insert(result, 1, string.char(digit+a))
|
|
n = math.floor(n/26)
|
|
end
|
|
if #result == 0 then
|
|
return 'a'
|
|
end
|
|
return table.concat(result)
|
|
end |