new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
19
Task/Caesar-cipher/Racket/caesar-cipher-1.rkt
Normal file
19
Task/Caesar-cipher/Racket/caesar-cipher-1.rkt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#lang racket
|
||||
|
||||
(define A (char->integer #\A))
|
||||
(define Z (char->integer #\Z))
|
||||
(define a (char->integer #\a))
|
||||
(define z (char->integer #\z))
|
||||
|
||||
(define (rotate c n)
|
||||
(define cnum (char->integer c))
|
||||
(define (shift base) (integer->char (+ base (modulo (+ n (- cnum base)) 26))))
|
||||
(cond [(<= A cnum Z) (shift A)]
|
||||
[(<= a cnum z) (shift a)]
|
||||
[else c]))
|
||||
|
||||
(define (caesar s n)
|
||||
(list->string (for/list ([c (in-string s)]) (rotate c n))))
|
||||
|
||||
(define (encrypt s) (caesar s 1))
|
||||
(define (decrypt s) (caesar s -1))
|
||||
5
Task/Caesar-cipher/Racket/caesar-cipher-2.rkt
Normal file
5
Task/Caesar-cipher/Racket/caesar-cipher-2.rkt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
> (define s (encrypt "The five boxing wizards jump quickly."))
|
||||
> s
|
||||
"Uif gjwf cpyjoh xjabset kvnq rvjdlmz."
|
||||
> (decrypt s)
|
||||
"The five boxing wizards jump quickly."
|
||||
Loading…
Add table
Add a link
Reference in a new issue