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/Red/caesar-cipher.red
Normal file
27
Task/Caesar-cipher/Red/caesar-cipher.red
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Red ["Ceasar Cipher"]
|
||||
|
||||
rot: func [
|
||||
char [char!]
|
||||
key [number!]
|
||||
ofs [char!]
|
||||
][
|
||||
to-char key + char - ofs // 26 + ofs
|
||||
]
|
||||
|
||||
caesar: function [
|
||||
src [string!]
|
||||
key [integer!]
|
||||
][
|
||||
lower: charset [#"a" - #"z"]
|
||||
upper: charset [#"A" - #"Z"]
|
||||
parse src [
|
||||
any [
|
||||
change s: [lower (o: #"a") | upper (o: #"A")] (rot s/1 key o)
|
||||
| skip
|
||||
]
|
||||
]
|
||||
src
|
||||
]
|
||||
|
||||
encrypt: :caesar
|
||||
decrypt: func spec-of :caesar [caesar src negate key]
|
||||
Loading…
Add table
Add a link
Reference in a new issue