Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
19
Task/Caesar-cipher/Phix/caesar-cipher.phix
Normal file
19
Task/Caesar-cipher/Phix/caesar-cipher.phix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
sequence alpha_b = repeat(0,255)
|
||||
alpha_b['A'..'Z'] = 'A'
|
||||
alpha_b['a'..'z'] = 'a'
|
||||
|
||||
function caesar(string s, integer key)
|
||||
integer ch, base
|
||||
for i=1 to length(s) do
|
||||
ch = s[i]
|
||||
base = alpha_b[ch]
|
||||
if base then
|
||||
s[i] = base+remainder(ch-base+key,26)
|
||||
end if
|
||||
end for
|
||||
return s
|
||||
end function
|
||||
string s = "One fine day in the middle of the night, two dead men got up to fight. \n"&
|
||||
"Back to back they faced each other, drew their swords and shot each other. %^&*()[",
|
||||
e = caesar(s,5),
|
||||
r = caesar(e,26-5) ?e ?r
|
||||
Loading…
Add table
Add a link
Reference in a new issue