mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-09-28 13:33:11 +08:00
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>
This commit is contained in:
co-authored by
pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Christian Clauss
pre-commit-ci[bot] <pre-commit-ci[bot]@users.noreply.github.com>
parent
7cc80db1f6
commit
54d784376f
@@ -357,6 +357,7 @@
|
||||
* [Middle Element Of Linked List](data_structures/linked_list/middle_element_of_linked_list.py)
|
||||
* [Partition Linked List](data_structures/linked_list/partition_linked_list.py)
|
||||
* [Print Reverse](data_structures/linked_list/print_reverse.py)
|
||||
* [Remove Nth Node From End Of List](data_structures/linked_list/remove_nth_node_from_end_of_list.py)
|
||||
* [Reverse K Group](data_structures/linked_list/reverse_k_group.py)
|
||||
* [Rotate To The Right](data_structures/linked_list/rotate_to_the_right.py)
|
||||
* [Singly Linked List](data_structures/linked_list/singly_linked_list.py)
|
||||
@@ -385,6 +386,7 @@
|
||||
* [Postfix Evaluation](data_structures/stacks/postfix_evaluation.py)
|
||||
* [Prefix Evaluation](data_structures/stacks/prefix_evaluation.py)
|
||||
* [Stack](data_structures/stacks/stack.py)
|
||||
* [Stack Tracking Min Max](data_structures/stacks/stack_tracking_min_max.py)
|
||||
* [Stack Using Two Queues](data_structures/stacks/stack_using_two_queues.py)
|
||||
* [Stack With Doubly Linked List](data_structures/stacks/stack_with_doubly_linked_list.py)
|
||||
* [Stack With Singly Linked List](data_structures/stacks/stack_with_singly_linked_list.py)
|
||||
@@ -939,6 +941,7 @@
|
||||
* [Catalan Number](maths/special_numbers/catalan_number.py)
|
||||
* [Deficient Numbers](maths/special_numbers/deficient_numbers.py)
|
||||
* [Disarum Number](maths/special_numbers/disarum_number.py)
|
||||
* [Evil Number](maths/special_numbers/evil_number.py)
|
||||
* [Hamming Numbers](maths/special_numbers/hamming_numbers.py)
|
||||
* [Happy Number](maths/special_numbers/happy_number.py)
|
||||
* [Harshad Numbers](maths/special_numbers/harshad_numbers.py)
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
"""
|
||||
|
||||
Note:
|
||||
This algorithm has memory persistence.
|
||||
So multiple runs on the same runtime will carry junk and scramble the result!
|
||||
"""
|
||||
|
||||
alphabets = [chr(i) for i in range(32, 126)]
|
||||
gear_one = list(range(len(alphabets)))
|
||||
gear_two = list(range(len(alphabets)))
|
||||
@@ -40,7 +47,22 @@ def engine(input_character) -> None:
|
||||
rotator()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def encode_or_decode(message, token):
|
||||
"""
|
||||
|
||||
>>> encode_or_decode("hello", 3)
|
||||
(['/', '0', "'", '%', ' '], 3)
|
||||
|
||||
"""
|
||||
|
||||
for _ in range(token):
|
||||
rotator()
|
||||
for j in message:
|
||||
engine(j)
|
||||
return code, token
|
||||
|
||||
|
||||
def menu():
|
||||
decode = list(input("Type your message:\n"))
|
||||
while True:
|
||||
try:
|
||||
@@ -57,3 +79,9 @@ if __name__ == "__main__":
|
||||
f"\nYour Token is {token} please write it down.\nIf you want to decode "
|
||||
"this message again you should input same digits as token!"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
|
||||
doctest.testmod()
|
||||
|
||||
Reference in New Issue
Block a user