Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework04 Чебукова 1.3 #280

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2f9ab51
Реализованы функции get_row, get_col, get_block
CheSunSunny Dec 6, 2024
a2893f4
Реализованы функции get_row, get_col, get_block
CheSunSunny Dec 6, 2024
02df6e1
Реализована функция find_possible_values
CheSunSunny Dec 6, 2024
21f67b9
Реализованы функции remove_wall и bin_tree_maze
CheSunSunny Jan 20, 2025
b54207c
Реализована функция get_exits
CheSunSunny Jan 21, 2025
9c33892
Функция encircled_exit прошла тест
CheSunSunny Jan 21, 2025
f0ee1d5
Функция remove_wall прошла тест
CheSunSunny Jan 21, 2025
12646d0
Исправлена функция remove_wall
CheSunSunny Jan 23, 2025
57b1728
Пройдены тесты на remove_wall и bin_tree_maze
CheSunSunny Jan 23, 2025
b1414cd
Пройден тест – test_make_step
CheSunSunny Jan 23, 2025
6d10b0a
Написана функция solve_maze
CheSunSunny Jan 23, 2025
5a18700
Пройден тест test_shortest_path
CheSunSunny Jan 23, 2025
9457304
Final commit: all done
CheSunSunny Jan 23, 2025
31e10c9
Changed workflows
CheSunSunny Jan 23, 2025
1213e62
Функция create_grid прошла тест
CheSunSunny Jan 23, 2025
cddd394
Написана функция draw_grid
CheSunSunny Jan 24, 2025
779c014
Исправлена функция draw_grid
CheSunSunny Jan 24, 2025
4c430fb
Пройдены тесты для get_neighbours
CheSunSunny Jan 24, 2025
4aa2201
Прототип готов
CheSunSunny Jan 24, 2025
e5d004d
Пройден test_get_next_generation
CheSunSunny Jan 24, 2025
b300694
Прошли все тесты для life.py
CheSunSunny Jan 24, 2025
9d46f31
Black
CheSunSunny Jan 24, 2025
cdab5ca
Changes
CheSunSunny Jan 24, 2025
31aa2ce
Attempt to fix
CheSunSunny Jan 24, 2025
a797bdb
Ran tests
CheSunSunny Jan 24, 2025
e037c6c
Ran tests again
CheSunSunny Jan 25, 2025
e115921
Ran tests again
CheSunSunny Jan 27, 2025
18e87ce
Ran tests again 2
CheSunSunny Jan 27, 2025
660205e
Ran tests again 3
CheSunSunny Jan 27, 2025
0cae207
Ran tests again 4
CheSunSunny Jan 27, 2025
040719e
Tests moved
CheSunSunny Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cs102.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install isort black pylint mypy
pip install isort black pylint mypy pandas pygame
- name: Install project dependencies
run: |
if [ -f ${{ github.head_ref }}/requirements.txt ];
Expand Down
43 changes: 43 additions & 0 deletions homework00/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion homework00/test_hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ class HelloTestCase(unittest.TestCase):
def test_hello(self):
m = "message"
self.assertEqual(m, hello_world.text())

171 changes: 171 additions & 0 deletions homework01/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion homework01/caesar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def decrypt_caesar(ciphertext: str, shift: int = 3) -> str:
"""
plaintext = ""
# PUT YOUR CODE HERE
return plaintext
return plaintext
8 changes: 5 additions & 3 deletions homework01/rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def multiplicative_inverse(e: int, phi: int) -> int:
pass


def generate_keypair(p: int, q: int) -> tp.Tuple[tp.Tuple[int, int], tp.Tuple[int, int]]:
def generate_keypair(
p: int, q: int
) -> tp.Tuple[tp.Tuple[int, int], tp.Tuple[int, int]]:
if not (is_prime(p) and is_prime(q)):
raise ValueError("Both numbers must be prime.")
elif p == q:
Expand Down Expand Up @@ -82,7 +84,7 @@ def decrypt(pk: tp.Tuple[int, int], ciphertext: tp.List[int]) -> str:
# Unpack the key into its components
key, n = pk
# Generate the plaintext based on the ciphertext and key using a^b mod m
plain = [chr((char ** key) % n) for char in ciphertext]
plain = [chr((char**key) % n) for char in ciphertext]
# Return the array of bytes as a string
return "".join(plain)

Expand All @@ -100,4 +102,4 @@ def decrypt(pk: tp.Tuple[int, int], ciphertext: tp.List[int]) -> str:
print("".join(map(lambda x: str(x), encrypted_msg)))
print("Decrypting message with public key ", public, " . . .")
print("Your message is:")
print(decrypt(public, encrypted_msg))
print(decrypt(public, encrypted_msg))
12 changes: 9 additions & 3 deletions homework01/tests/test_caesar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def test_encrypt(self):

for i, (plaintext, shift, chiphertext) in enumerate(cases):
with self.subTest(case=i, plaintext=plaintext, chiphertext=chiphertext):
self.assertEqual(chiphertext, caesar.encrypt_caesar(plaintext, shift=shift))
self.assertEqual(
chiphertext, caesar.encrypt_caesar(plaintext, shift=shift)
)

def test_decrypt(self):
cases = [
Expand All @@ -40,11 +42,15 @@ def test_decrypt(self):

for i, (chiphertext, shift, plaintext) in enumerate(cases):
with self.subTest(case=i, chiphertext=chiphertext, plaintext=plaintext):
self.assertEqual(plaintext, caesar.decrypt_caesar(chiphertext, shift=shift))
self.assertEqual(
plaintext, caesar.decrypt_caesar(chiphertext, shift=shift)
)

def test_randomized(self):
shift = random.randint(8, 24)
plaintext = "".join(random.choice(string.ascii_letters + " -,") for _ in range(64))
plaintext = "".join(
random.choice(string.ascii_letters + " -,") for _ in range(64)
)
ciphertext = caesar.encrypt_caesar(plaintext, shift=shift)
self.assertEqual(
plaintext,
Expand Down
6 changes: 4 additions & 2 deletions homework01/tests/test_rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def test_multiplicative_inverse(self):
def test_generate_keypair(self):
random.seed(1234567)
self.assertEqual(((121, 323), (169, 323)), rsa.generate_keypair(17, 19))
self.assertEqual(((142169, 1697249), (734969, 1697249)), rsa.generate_keypair(1229, 1381))
self.assertEqual(
((142169, 1697249), (734969, 1697249)), rsa.generate_keypair(1229, 1381)
)
self.assertEqual(
((9678731, 11188147), (1804547, 11188147)), rsa.generate_keypair(3259, 3433)
)
)
16 changes: 11 additions & 5 deletions homework01/tests/test_vigenere.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def test_encrypt(self):
with self.subTest(
case=i, plaintext=plaintext, keyword=keyword, chiphertext=chiphertext
):
self.assertEqual(chiphertext, vigenere.encrypt_vigenere(plaintext, keyword))
self.assertEqual(
chiphertext, vigenere.encrypt_vigenere(plaintext, keyword)
)

def test_decrypt(self):
cases = [
Expand All @@ -32,11 +34,15 @@ def test_decrypt(self):
with self.subTest(
case=i, chiphertext=chiphertext, keyword=keyword, plaintext=plaintext
):
self.assertEqual(plaintext, vigenere.decrypt_vigenere(chiphertext, keyword))
self.assertEqual(
plaintext, vigenere.decrypt_vigenere(chiphertext, keyword)
)

def test_randomized(self):
kwlen = random.randint(4, 24)
keyword = ''.join(random.choice(string.ascii_letters) for _ in range(kwlen))
plaintext = ''.join(random.choice(string.ascii_letters + ' -,') for _ in range(64))
keyword = "".join(random.choice(string.ascii_letters) for _ in range(kwlen))
plaintext = "".join(
random.choice(string.ascii_letters + " -,") for _ in range(64)
)
ciphertext = vigenere.encrypt_vigenere(plaintext, keyword)
self.assertEqual(plaintext, vigenere.decrypt_vigenere(ciphertext, keyword))
self.assertEqual(plaintext, vigenere.decrypt_vigenere(ciphertext, keyword))
2 changes: 1 addition & 1 deletion homework01/vigenere.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def decrypt_vigenere(ciphertext: str, keyword: str) -> str:
"""
plaintext = ""
# PUT YOUR CODE HERE
return plaintext
return plaintext
Loading
Loading