Data update

This commit is contained in:
Ingy döt Net 2023-12-16 21:33:55 -08:00
parent 35bcdeebf8
commit 74c69a0df6
2427 changed files with 31826 additions and 3468 deletions

View 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

View file

@ -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);
});
}

View file

@ -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));

View file

@ -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()