Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
20
Task/Caesar-cipher/Pluto/caesar-cipher.pluto
Normal file
20
Task/Caesar-cipher/Pluto/caesar-cipher.pluto
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
local function caesar(s, k, e=true)
|
||||
-- Parameters: s (string), k (key)
|
||||
-- e (true=encode, false=decode)
|
||||
if !e do k=-k end
|
||||
local out = ""
|
||||
for i = 1, #s do
|
||||
local c = s[i]
|
||||
if c:islower() then
|
||||
out ..= string.char((c:byte() - 97 + k) % 26 + 97)
|
||||
elseif c:isupper() then
|
||||
out ..= string.char((c:byte() - 65 + k) % 26 + 65)
|
||||
else
|
||||
out ..= c
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
print(caesar("The quick brown fox jumps over the lazy dog.", 3))
|
||||
print(caesar("Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj.", 3, false))
|
||||
Loading…
Add table
Add a link
Reference in a new issue