mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
feat(challenges): add caesar-cipher
This commit is contained in:
parent
99d5290e49
commit
01804ace41
34
challenges/caesar-cipher/README.md
Normal file
34
challenges/caesar-cipher/README.md
Normal file
@ -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.
|
0
challenges/caesar-cipher/solutions/.gitkeep
Normal file
0
challenges/caesar-cipher/solutions/.gitkeep
Normal file
2
challenges/caesar-cipher/test/1/input.txt
Normal file
2
challenges/caesar-cipher/test/1/input.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ANTHONY
|
||||||
|
-2
|
1
challenges/caesar-cipher/test/1/output.txt
Normal file
1
challenges/caesar-cipher/test/1/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
YLRFMLW
|
2
challenges/caesar-cipher/test/2/input.txt
Normal file
2
challenges/caesar-cipher/test/2/input.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
|
||||||
|
-23
|
1
challenges/caesar-cipher/test/2/output.txt
Normal file
1
challenges/caesar-cipher/test/2/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ
|
2
challenges/caesar-cipher/test/3/input.txt
Normal file
2
challenges/caesar-cipher/test/3/input.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
PROGRAMMING CHALLENGES IS AWESOME
|
||||||
|
-12
|
1
challenges/caesar-cipher/test/3/output.txt
Normal file
1
challenges/caesar-cipher/test/3/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
DFCUFOAAWBU QVOZZSBUSG WG OKSGCAS
|
2
challenges/caesar-cipher/test/4/input.txt
Normal file
2
challenges/caesar-cipher/test/4/input.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
JVUNYHABSHAPVUZ
|
||||||
|
-19
|
1
challenges/caesar-cipher/test/4/output.txt
Normal file
1
challenges/caesar-cipher/test/4/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
QCBUFOHIZOHWCBG
|
2
challenges/caesar-cipher/test/5/input.txt
Normal file
2
challenges/caesar-cipher/test/5/input.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
JAVASCRIPT
|
||||||
|
-11
|
1
challenges/caesar-cipher/test/5/output.txt
Normal file
1
challenges/caesar-cipher/test/5/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
YPKPHRGXEI
|
2
challenges/caesar-cipher/test/6/input.txt
Normal file
2
challenges/caesar-cipher/test/6/input.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
HEY
|
||||||
|
5
|
1
challenges/caesar-cipher/test/6/output.txt
Normal file
1
challenges/caesar-cipher/test/6/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
MJD
|
2
challenges/caesar-cipher/test/7/input.txt
Normal file
2
challenges/caesar-cipher/test/7/input.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
CODING DOJO
|
||||||
|
0
|
1
challenges/caesar-cipher/test/7/output.txt
Normal file
1
challenges/caesar-cipher/test/7/output.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
CODING DOJO
|
Loading…
Reference in New Issue
Block a user