Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
15
Task/Caesar-cipher/EasyLang/caesar-cipher.easy
Normal file
15
Task/Caesar-cipher/EasyLang/caesar-cipher.easy
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
func$ crypt str$ key .
|
||||
for c$ in strchars str$
|
||||
c = strcode c$
|
||||
if c >= 65 and c <= 90
|
||||
c = (c + key - 65) mod 26 + 65
|
||||
elif c >= 97 and c <= 122
|
||||
c = (c + key - 97) mod 26 + 97
|
||||
.
|
||||
enc$ &= strchar c
|
||||
.
|
||||
return enc$
|
||||
.
|
||||
enc$ = crypt "Rosetta Code" 4
|
||||
print enc$
|
||||
print crypt enc$ -4
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
function caesar (text, shift) {
|
||||
return text.toUpperCase().replace(/[^A-Z]/g,'').replace(/./g, function(a) {
|
||||
return String.fromCharCode(65+(a.charCodeAt(0)-65+shift)%26);
|
||||
return String.fromCharCode(((a.charCodeAt(0) - 65 + shift) % 26 + 26) % 26 + 65);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ var caesar = (text, shift) => text
|
|||
.toUpperCase()
|
||||
.replace(/[^A-Z]/g, '')
|
||||
.replace(/./g, a =>
|
||||
String.fromCharCode(65 + (a.charCodeAt(0) - 65 + shift) % 26));
|
||||
String.fromCharCode(((a.charCodeAt(0) - 65 + shift) % 26 + 26) % 26 + 65));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import rand
|
||||
|
||||
const
|
||||
(
|
||||
const (
|
||||
lo_abc = 'abcdefghijklmnopqrstuvwxyz'
|
||||
up_abc = 'ABCDEFGHIJKLMNIPQRSTUVWXYZ'
|
||||
)
|
||||
|
|
@ -27,9 +26,7 @@ fn caesar_encrypt(str string, key int) string {
|
|||
nchr = chr + u8(offset)
|
||||
if nchr > u8(122) {nchr -= 26}
|
||||
}
|
||||
else {
|
||||
nchr = chr
|
||||
}
|
||||
else {nchr = chr}
|
||||
chr_arr << nchr
|
||||
}
|
||||
return chr_arr.bytestr()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue