Skip to content

Commit 54d7843

Browse files
gabriellypintopre-commit-ci[bot]cclauss
authored
add tests for enigma_machine (#10017)
* add tests for enigma_machine * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * typo * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * updating DIRECTORY.md --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: pre-commit-ci[bot] <pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7cc80db commit 54d7843

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

‎DIRECTORY.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@
357357
* [Middle Element Of Linked List](data_structures/linked_list/middle_element_of_linked_list.py)
358358
* [Partition Linked List](data_structures/linked_list/partition_linked_list.py)
359359
* [Print Reverse](data_structures/linked_list/print_reverse.py)
360+
* [Remove Nth Node From End Of List](data_structures/linked_list/remove_nth_node_from_end_of_list.py)
360361
* [Reverse K Group](data_structures/linked_list/reverse_k_group.py)
361362
* [Rotate To The Right](data_structures/linked_list/rotate_to_the_right.py)
362363
* [Singly Linked List](data_structures/linked_list/singly_linked_list.py)
@@ -385,6 +386,7 @@
385386
* [Postfix Evaluation](data_structures/stacks/postfix_evaluation.py)
386387
* [Prefix Evaluation](data_structures/stacks/prefix_evaluation.py)
387388
* [Stack](data_structures/stacks/stack.py)
389+
* [Stack Tracking Min Max](data_structures/stacks/stack_tracking_min_max.py)
388390
* [Stack Using Two Queues](data_structures/stacks/stack_using_two_queues.py)
389391
* [Stack With Doubly Linked List](data_structures/stacks/stack_with_doubly_linked_list.py)
390392
* [Stack With Singly Linked List](data_structures/stacks/stack_with_singly_linked_list.py)
@@ -939,6 +941,7 @@
939941
* [Catalan Number](maths/special_numbers/catalan_number.py)
940942
* [Deficient Numbers](maths/special_numbers/deficient_numbers.py)
941943
* [Disarum Number](maths/special_numbers/disarum_number.py)
944+
* [Evil Number](maths/special_numbers/evil_number.py)
942945
* [Hamming Numbers](maths/special_numbers/hamming_numbers.py)
943946
* [Happy Number](maths/special_numbers/happy_number.py)
944947
* [Harshad Numbers](maths/special_numbers/harshad_numbers.py)

‎hashes/enigma_machine.py‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""
2+
3+
Note:
4+
This algorithm has memory persistence.
5+
So multiple runs on the same runtime will carry junk and scramble the result!
6+
"""
7+
18
alphabets = [chr(i) for i in range(32, 126)]
29
gear_one = list(range(len(alphabets)))
310
gear_two = list(range(len(alphabets)))
@@ -40,7 +47,22 @@ def engine(input_character) -> None:
4047
rotator()
4148

4249

43-
if __name__ == "__main__":
50+
def encode_or_decode(message, token):
51+
"""
52+
53+
>>> encode_or_decode("hello", 3)
54+
(['/', '0', "'", '%', ' '], 3)
55+
56+
"""
57+
58+
for _ in range(token):
59+
rotator()
60+
for j in message:
61+
engine(j)
62+
return code, token
63+
64+
65+
def menu():
4466
decode = list(input("Type your message:\n"))
4567
while True:
4668
try:
@@ -57,3 +79,9 @@ def engine(input_character) -> None:
5779
f"\nYour Token is {token} please write it down.\nIf you want to decode "
5880
"this message again you should input same digits as token!"
5981
)
82+
83+
84+
if __name__ == "__main__":
85+
import doctest
86+
87+
doctest.testmod()

0 commit comments

Comments
 (0)