Skip to content

Commit 827b323

Browse files
Quicken src/reactivity_visualizer.py and 2 more (#15)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 9bc0248 commit 827b323

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/banana_recipes_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# src/banana_recipes_test.py
2+
3+
def test_banana_pudding():
4+
assert banana_pudding() == "Banana Pudding recipe ready!"
5+
6+
def test_rot13_encryptor():
7+
assert rot13_encryptor("test") == "uryyb"

src/encrypt_decrypt_module.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from typing import *
2+
import random
3+
4+
class RotateCipher:
5+
def __init__(self, key):
6+
self.key = key
7+
8+
def encrypt(self, message):
9+
encrypted = ""
10+
for char in message:
11+
if char.isalpha():
12+
ascii_offset = ord('A') if char.isupper() else ord('a')
13+
new_char = chr((ord(char) - ascii_offset + self.key) % 26 + ascii_offset)
14+
encrypted += new_char
15+
else:
16+
encrypted += char
17+
return encrypted
18+
19+
def decrypt(self, message):
20+
decrypted = ""
21+
for char in message:
22+
if char.isalpha():
23+
ascii_offset = ord('A') if char.isupper() else ord('a')
24+
new_char = chr((ord(char) - ascii_offset - self.key) % 26 + ascii_offset)
25+
decrypted += new_char
26+
else:
27+
decrypted += char
28+
return decrypted
29+
30+
# Example usage
31+
cipher = RotateCipher(KEY)
32+
original_message = "HELLO WORLD!"
33+
encrypted_message = cipher.encrypt(original_message)
34+
print("Encrypted:", encrypted_message)
35+
36+
decrypted_message = cipher.decrypt(encrypted_message)
37+
print("Decrypted:", decrypted_message)

src/reactivity_visualizer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ def forward(self, x):
4343

4444
running_loss += loss.item()
4545
print(f'Epoch [{epoch+1}/{3}], Loss: {running_loss/len(train_loader)}')
46+
obj['output']

0 commit comments

Comments
 (0)