From 01804ace410e4d6b376a9f70b99bd3668d191679 Mon Sep 17 00:00:00 2001 From: Divlo Date: Fri, 25 Jun 2021 13:45:14 +0200 Subject: [PATCH] feat(challenges): add `caesar-cipher` --- challenges/caesar-cipher/README.md | 34 +++++++++++++++++++++ challenges/caesar-cipher/solutions/.gitkeep | 0 challenges/caesar-cipher/test/1/input.txt | 2 ++ challenges/caesar-cipher/test/1/output.txt | 1 + challenges/caesar-cipher/test/2/input.txt | 2 ++ challenges/caesar-cipher/test/2/output.txt | 1 + challenges/caesar-cipher/test/3/input.txt | 2 ++ challenges/caesar-cipher/test/3/output.txt | 1 + challenges/caesar-cipher/test/4/input.txt | 2 ++ challenges/caesar-cipher/test/4/output.txt | 1 + challenges/caesar-cipher/test/5/input.txt | 2 ++ challenges/caesar-cipher/test/5/output.txt | 1 + challenges/caesar-cipher/test/6/input.txt | 2 ++ challenges/caesar-cipher/test/6/output.txt | 1 + challenges/caesar-cipher/test/7/input.txt | 2 ++ challenges/caesar-cipher/test/7/output.txt | 1 + 16 files changed, 55 insertions(+) create mode 100644 challenges/caesar-cipher/README.md create mode 100644 challenges/caesar-cipher/solutions/.gitkeep create mode 100644 challenges/caesar-cipher/test/1/input.txt create mode 100644 challenges/caesar-cipher/test/1/output.txt create mode 100644 challenges/caesar-cipher/test/2/input.txt create mode 100644 challenges/caesar-cipher/test/2/output.txt create mode 100644 challenges/caesar-cipher/test/3/input.txt create mode 100644 challenges/caesar-cipher/test/3/output.txt create mode 100644 challenges/caesar-cipher/test/4/input.txt create mode 100644 challenges/caesar-cipher/test/4/output.txt create mode 100644 challenges/caesar-cipher/test/5/input.txt create mode 100644 challenges/caesar-cipher/test/5/output.txt create mode 100644 challenges/caesar-cipher/test/6/input.txt create mode 100644 challenges/caesar-cipher/test/6/output.txt create mode 100644 challenges/caesar-cipher/test/7/input.txt create mode 100644 challenges/caesar-cipher/test/7/output.txt diff --git a/challenges/caesar-cipher/README.md b/challenges/caesar-cipher/README.md new file mode 100644 index 0000000..5e6a7a3 --- /dev/null +++ b/challenges/caesar-cipher/README.md @@ -0,0 +1,34 @@ +# caesar-cipher + +Created by [@Divlo](https://github.com/Divlo) on 25 June 2021. + +## Instructions + +In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of -3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence. + +### Example of the alphabet with a shift of +3 (shift to the right) + +```text +Alphabet original : ABCDEFGHIJKLMNOPQRSTUVWXYZ +Alphabet rotated +3 : DEFGHIJKLMNOPQRSTUVWXYZABC +``` + +Create a function that will return the sentence after shifting the alphabet. + +- If it is a **positive** number then we shift the alphabet to the **right** +- If it is a **negative** number then we shift the alphabet to the **left** + +### Example of Inputs + +```py +'ANTHONY' # a character string (all capital letters) +'-2' # an integer, the shift in the alphabet +``` + +## Source + +- [Wikipedia - Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher) + +## Examples + +See the `test` folder for examples of input/output. diff --git a/challenges/caesar-cipher/solutions/.gitkeep b/challenges/caesar-cipher/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/caesar-cipher/test/1/input.txt b/challenges/caesar-cipher/test/1/input.txt new file mode 100644 index 0000000..0d1566d --- /dev/null +++ b/challenges/caesar-cipher/test/1/input.txt @@ -0,0 +1,2 @@ +ANTHONY +-2 \ No newline at end of file diff --git a/challenges/caesar-cipher/test/1/output.txt b/challenges/caesar-cipher/test/1/output.txt new file mode 100644 index 0000000..3069fb6 --- /dev/null +++ b/challenges/caesar-cipher/test/1/output.txt @@ -0,0 +1 @@ +YLRFMLW \ No newline at end of file diff --git a/challenges/caesar-cipher/test/2/input.txt b/challenges/caesar-cipher/test/2/input.txt new file mode 100644 index 0000000..1d3ca77 --- /dev/null +++ b/challenges/caesar-cipher/test/2/input.txt @@ -0,0 +1,2 @@ +THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG +-23 \ No newline at end of file diff --git a/challenges/caesar-cipher/test/2/output.txt b/challenges/caesar-cipher/test/2/output.txt new file mode 100644 index 0000000..4e28e8e --- /dev/null +++ b/challenges/caesar-cipher/test/2/output.txt @@ -0,0 +1 @@ +WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ \ No newline at end of file diff --git a/challenges/caesar-cipher/test/3/input.txt b/challenges/caesar-cipher/test/3/input.txt new file mode 100644 index 0000000..8b7d847 --- /dev/null +++ b/challenges/caesar-cipher/test/3/input.txt @@ -0,0 +1,2 @@ +PROGRAMMING CHALLENGES IS AWESOME +-12 \ No newline at end of file diff --git a/challenges/caesar-cipher/test/3/output.txt b/challenges/caesar-cipher/test/3/output.txt new file mode 100644 index 0000000..00558b3 --- /dev/null +++ b/challenges/caesar-cipher/test/3/output.txt @@ -0,0 +1 @@ +DFCUFOAAWBU QVOZZSBUSG WG OKSGCAS \ No newline at end of file diff --git a/challenges/caesar-cipher/test/4/input.txt b/challenges/caesar-cipher/test/4/input.txt new file mode 100644 index 0000000..926596e --- /dev/null +++ b/challenges/caesar-cipher/test/4/input.txt @@ -0,0 +1,2 @@ +JVUNYHABSHAPVUZ +-19 \ No newline at end of file diff --git a/challenges/caesar-cipher/test/4/output.txt b/challenges/caesar-cipher/test/4/output.txt new file mode 100644 index 0000000..d701e4b --- /dev/null +++ b/challenges/caesar-cipher/test/4/output.txt @@ -0,0 +1 @@ +QCBUFOHIZOHWCBG \ No newline at end of file diff --git a/challenges/caesar-cipher/test/5/input.txt b/challenges/caesar-cipher/test/5/input.txt new file mode 100644 index 0000000..8292041 --- /dev/null +++ b/challenges/caesar-cipher/test/5/input.txt @@ -0,0 +1,2 @@ +JAVASCRIPT +-11 \ No newline at end of file diff --git a/challenges/caesar-cipher/test/5/output.txt b/challenges/caesar-cipher/test/5/output.txt new file mode 100644 index 0000000..f204127 --- /dev/null +++ b/challenges/caesar-cipher/test/5/output.txt @@ -0,0 +1 @@ +YPKPHRGXEI \ No newline at end of file diff --git a/challenges/caesar-cipher/test/6/input.txt b/challenges/caesar-cipher/test/6/input.txt new file mode 100644 index 0000000..103d8b7 --- /dev/null +++ b/challenges/caesar-cipher/test/6/input.txt @@ -0,0 +1,2 @@ +HEY +5 \ No newline at end of file diff --git a/challenges/caesar-cipher/test/6/output.txt b/challenges/caesar-cipher/test/6/output.txt new file mode 100644 index 0000000..2bc1619 --- /dev/null +++ b/challenges/caesar-cipher/test/6/output.txt @@ -0,0 +1 @@ +MJD \ No newline at end of file diff --git a/challenges/caesar-cipher/test/7/input.txt b/challenges/caesar-cipher/test/7/input.txt new file mode 100644 index 0000000..c83d4b3 --- /dev/null +++ b/challenges/caesar-cipher/test/7/input.txt @@ -0,0 +1,2 @@ +CODING DOJO +0 \ No newline at end of file diff --git a/challenges/caesar-cipher/test/7/output.txt b/challenges/caesar-cipher/test/7/output.txt new file mode 100644 index 0000000..8ba7839 --- /dev/null +++ b/challenges/caesar-cipher/test/7/output.txt @@ -0,0 +1 @@ +CODING DOJO \ No newline at end of file