Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Caesar-cipher/AppleScript/caesar-cipher-1.applescript
Normal file
27
Task/Caesar-cipher/AppleScript/caesar-cipher-1.applescript
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(* Only non-accented English letters are altered here. *)
|
||||
|
||||
on caesarDecipher(txt, |key|)
|
||||
return caesarEncipher(txt, -|key|)
|
||||
end caesarDecipher
|
||||
|
||||
on caesarEncipher(txt, |key|)
|
||||
set codePoints to id of txt
|
||||
set keyPlus25 to |key| mod 26 + 25
|
||||
repeat with thisCode in codePoints
|
||||
tell thisCode mod 32
|
||||
if ((it < 27) and (it > 0) and (thisCode div 64 is 1)) then ¬
|
||||
set thisCode's contents to thisCode - it + (it + keyPlus25) mod 26 + 1
|
||||
end tell
|
||||
end repeat
|
||||
|
||||
return string id codePoints
|
||||
end caesarEncipher
|
||||
|
||||
-- Test code:
|
||||
set txt to "ROMANES EUNT DOMUS!
|
||||
The quick brown fox jumps over the lazy dog."
|
||||
set |key| to 9
|
||||
|
||||
set enciphered to caesarEncipher(txt, |key|)
|
||||
set deciphered to caesarDecipher(enciphered, |key|)
|
||||
return "Text: '" & txt & ("'" & linefeed & "Key: " & |key| & linefeed & linefeed) & (enciphered & linefeed & deciphered)
|
||||
Loading…
Add table
Add a link
Reference in a new issue