Hex
New Member
Posts: 19
|
Post by Hex on Jun 6, 2017 12:24:07 GMT
DIFFICULTY: MEDIUM
Given the string "TJ,TPJ&OP)D*P(OBDMP*W$P-D'J"MJ(TDJ*QP/D,TPS.D&JNB/SU#MVP!O'P$NVFO)q," derive from it the string "Pneumonoultramicroscopicsilicovolcanoconiosis"
|
|
|
Post by cntkillme on Jun 12, 2017 10:44:52 GMT
> Get rid of non-alpha chars > Reverse string > Flip case > Subtract 1
local s = [[TJ,TPJ&OP)D*P(OBDMP*W$P-D'J"MJ(TDJ*QP/D,TPS.D&JNB/SU#MVP!O'P$NVFO)q]] s = s:gsub("%A", ""):reverse() -- step 1, 2 s = s:sub(1, 1):upper() .. s:sub(2):lower() -- step 3 s = s:gsub("%a", function(v) return string.char(v:byte() - 1) end) -- step 4 print(s)
|
|