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
28
Task/Caesar-cipher/Ursa/caesar-cipher.ursa
Normal file
28
Task/Caesar-cipher/Ursa/caesar-cipher.ursa
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
decl string mode
|
||||
while (not (or (= mode "encode") (= mode "decode")))
|
||||
out "encode/decode: " console
|
||||
set mode (lower (in string console))
|
||||
end while
|
||||
|
||||
decl string message
|
||||
out "message: " console
|
||||
set message (upper (in string console))
|
||||
|
||||
decl int key
|
||||
out "key: " console
|
||||
set key (in int console)
|
||||
if (or (> key 26) (< key 0))
|
||||
out endl "invalid key" endl console
|
||||
stop
|
||||
end if
|
||||
|
||||
if (= mode "decode")
|
||||
set key (int (- 26 key))
|
||||
end if
|
||||
|
||||
for (decl int i) (< i (size message)) (inc i)
|
||||
if (and (> (ord message<i>) 64) (< (ord message<i>) 91))
|
||||
out (chr (int (+ (mod (int (+ (- (ord message<i>) 65) key)) 26) 65))) console
|
||||
end if
|
||||
end for
|
||||
out endl console
|
||||
Loading…
Add table
Add a link
Reference in a new issue