Compare commits
No commits in common. "883e9c94ec356699d8a6e7690c6341622d2bc72b" and "afade771fa166341ff6d795f35a0de07a50318e1" have entirely different histories.
883e9c94ec
...
afade771fa
2 changed files with 16 additions and 89 deletions
59
Tasks.md
59
Tasks.md
|
@ -282,53 +282,12 @@ Use [regex101.com](https://regex101.com) if you are not already a REGEX expert.
|
||||||
|
|
||||||
There should be $374$ matches.
|
There should be $374$ matches.
|
||||||
|
|
||||||
A regex that matches the requirements is `\b[a-z][AEIOUaeiou]([a-w]|[A-W])`.
|
A regex that fullfills the requirements is `\b[a-z][AEIOUaeiou]([a-w]|[A-W])`.
|
||||||
|
|
||||||
[Code Example](src/tasks/regex.py)
|
[Code Example](src/tasks/regex.py)
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Ancient Cryptography
|
|
||||||
|
|
||||||
Difficulty: 2/5
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Text</summary>
|
|
||||||
|
|
||||||
```text
|
|
||||||
Neovim is a refactor, and sometimes redactor, in the tradition of Vim (which itself derives from
|
|
||||||
Stevie). It is not a rewrite but a continuation and extension of Vim. Many clones and derivatives
|
|
||||||
exist, some very clever—but none are Vim. Neovim is built for users who want the good parts of
|
|
||||||
Vim, and more.
|
|
||||||
````
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
1. The text above has been cyphered with the Caesar cipher, a timeless classic
|
|
||||||
algorithm to abstract the meaning away from a text and arguably an early
|
|
||||||
form of encryption. Your task is to decipher it back into readable text.
|
|
||||||
|
|
||||||
### The Caesar cipher
|
|
||||||
|
|
||||||
For the Caesar cipher, all letters are shifted by the value of the key.
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
`foo Bar` becomes `gpp Cbs` when shifted by $1$.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Hints</summary>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
<details>
|
|
||||||
<summary>Solution</summary>
|
|
||||||
|
|
||||||
[Code Example](src/caesar.py)
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Making a Hexeditor
|
## Making a Hexeditor
|
||||||
|
|
||||||
In this section, we're building a little hexeditor. You will be able to install
|
In this section, we're building a little hexeditor. You will be able to install
|
||||||
|
@ -357,7 +316,7 @@ Difficulty: 2/5
|
||||||
|
|
||||||
|
|
||||||
1. Dump the data of [data/metasyntactic.md](./data/metasyntactic.md) -- In
|
1. Dump the data of [data/metasyntactic.md](./data/metasyntactic.md) -- In
|
||||||
Hexadecimal.
|
Hexadecumal.
|
||||||
2. Make the dumped Bytes look pretty, something like the example below:
|
2. Make the dumped Bytes look pretty, something like the example below:
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -388,4 +347,18 @@ Line Data
|
||||||
0000110 ┃ 6d20 7465 7361 6e79 6174 7463 6369 7620
|
0000110 ┃ 6d20 7465 7361 6e79 6174 7463 6369 7620
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Hints</summary>
|
||||||
|
|
||||||
|
TODO: add hints
|
||||||
|
|
||||||
|
</details>
|
||||||
|
<details>
|
||||||
|
<summary>Solution</summary>
|
||||||
|
|
||||||
|
TODO: formulate solution text
|
||||||
|
|
||||||
|
[Code Example](src/tasks/hexdumper-a.py)
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def internal(text: str, key: int) -> str:
|
|
||||||
cyphertext: str = ""
|
|
||||||
for c in text:
|
|
||||||
if ord(c) >= 65 and ord(c) <= 90: # uppercase letters
|
|
||||||
ci = ord(c) - ord('A')
|
|
||||||
add = ord('A')
|
|
||||||
#print(f"{c} is uppercase")
|
|
||||||
elif ord(c) >= 97 and ord(c) <= 122: # uppercase letters
|
|
||||||
ci = ord(c) - ord('a')
|
|
||||||
add = ord('a')
|
|
||||||
#print(f"{c} is lowercase")
|
|
||||||
else:
|
|
||||||
#print(f"not a letter: {c} ({ord(c)})")
|
|
||||||
# character is not a letter, just skip it
|
|
||||||
cyphertext += c
|
|
||||||
continue
|
|
||||||
ci += key
|
|
||||||
ci %= 26 # only 23 letters in the alphabet
|
|
||||||
#print(f"ci for {c}: {ci}")
|
|
||||||
cyphertext += chr(ci + add)
|
|
||||||
|
|
||||||
return cyphertext
|
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) <= 2 or len(sys.argv) >= 5:
|
|
||||||
print("Takes two arguments: <SOURCE> <KEY> [-e]")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
source: str = sys.argv[1]
|
|
||||||
target: str = ""
|
|
||||||
key = int(sys.argv[2])
|
|
||||||
|
|
||||||
if len(sys.argv) >= 4 and sys.argv[3] == "-e":
|
|
||||||
print("encrypting...")
|
|
||||||
target = internal(source, -key)
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
|
||||||
print("decrypting...")
|
|
||||||
target = internal(source, key)
|
|
||||||
|
|
||||||
print("=" * 80)
|
|
||||||
print("%s" % target)
|
|
Loading…
Add table
Reference in a new issue