-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f628688
commit e567db7
Showing
6 changed files
with
11,925 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(ns main) | ||
|
||
(defn in? [start end val] | ||
(and (>= val start) (<= val end))) | ||
|
||
(defn letter? [char] | ||
(or (in? 65 90 (int char)) | ||
(in? 97 122 (int char)))) | ||
|
||
(defn encrypt [string] | ||
(loop [index (dec (count string))] | ||
(let [current-char (.charAt string index) | ||
encrypted-char (if (letter? current-char) | ||
(char (+ (int current-char) 3)) | ||
current-char) | ||
encrypted-char (if (< index (/ (count string) 2)) | ||
(char (- (int encrypted-char) 1)) | ||
encrypted-char)] | ||
(printf "%c" encrypted-char)) | ||
(if (> index 0) | ||
(recur (dec index)) | ||
(printf "%n")))) | ||
|
||
(defn main [] | ||
(loop [n (Integer/parseInt (read-line))] | ||
(let [line (read-line)] | ||
(encrypt line)) | ||
(when (> n 1) | ||
(recur (dec n))))) | ||
|
||
(main) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
TESTCASES=4062 | ||
MAX_CHARS_PER_LINE=1000 | ||
|
||
function chr { | ||
printf \\$(printf '%03o' $1) | ||
} | ||
|
||
echo "${TESTCASES}" | ||
for _ in $(seq "${TESTCASES}"); do | ||
for _ in $(seq $((RANDOM % MAX_CHARS_PER_LINE + 1))); do | ||
chr "$((RANDOM % 94 + 33))" | ||
done | ||
echo | ||
done |
Oops, something went wrong.