tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
12
Task/Rot-13/Clojure/rot-13-1.clj
Normal file
12
Task/Rot-13/Clojure/rot-13-1.clj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(defn rot-13 [c]
|
||||
(let [i (int c)]
|
||||
(cond
|
||||
(or (and (>= i (int \a)) (<= i (int \m)))
|
||||
(and (>= i (int \A)) (<= i (int \M))))
|
||||
(char (+ i 13))
|
||||
(or (and (>= i (int \n)) (<= i (int \z)))
|
||||
(and (>= i (int \N)) (<= i (int \Z))))
|
||||
(char (- i 13))
|
||||
:else c)))
|
||||
|
||||
(apply str (map rot-13 "abcxyzABCXYZ")) ;; output "nopklmNOPKLM"
|
||||
7
Task/Rot-13/Clojure/rot-13-2.clj
Normal file
7
Task/Rot-13/Clojure/rot-13-2.clj
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(let [A (into #{} "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
A-map (zipmap A (take 52 (drop 26 (cycle A))))]
|
||||
|
||||
(defn rot13[in-str]
|
||||
(reduce str (map #(if (A %1) (A-map %1) %1) in-str))))
|
||||
|
||||
(rot13 "The Quick Brown Fox Jumped Over The Lazy Dog!") ;; produces "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue