1def plugboard(input, pairs):
2 res = []
3
4 for ch in input:
5 replaced = False
6 for key, value in pairs:
7 if ch == key:
8 res.append(value)
9 replaced = True
10 break
11 if ch == value:
12 res.append(key)
13 replaced = True
14 break
15
16 if not replaced:
17 res.append(ch)
18
19 return ''.join(res)
20
21def rotor(input, pairs):
22 res = []
23
24 for ch in input:
25 if ch in pairs:
26 res.append(pairs[ch])
27 else:
28 res.append(ch)
29
30 return ''.join(res)
EEEE.....
======================================================================
ERROR: test_full_letter_set (test.TestCombination)
Test decrypting an encrypted text against itself.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 136, in test_full_letter_set
encryptor = enigma_encrypt(self.PLUGBOARD_POSITION, self.ROTOR_POSITION)
NameError: name 'enigma_encrypt' is not defined
======================================================================
ERROR: test_correct_decorator_order (test.TestDecorators)
Test whether the decorator is applying the functions in correct order.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 162, in test_correct_decorator_order
encryptor = enigma_encrypt(self.PLUGBOARD_POSITION, self.ROTOR_POSITION)
NameError: name 'enigma_encrypt' is not defined
======================================================================
ERROR: test_full_letter_set (test.TestDecryptor)
Test the decryptor function with all letters in the rotor.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 110, in test_full_letter_set
decryptor = enigma_decrypt(self.PLUGBOARD_POSITION, self.ROTOR_POSITION)
NameError: name 'enigma_decrypt' is not defined
======================================================================
ERROR: test_full_letter_set (test.TestEncryptor)
Test the encryptor function with all letters in the rotor.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 87, in test_full_letter_set
encryptor = enigma_encrypt(self.PLUGBOARD_POSITION, self.ROTOR_POSITION)
NameError: name 'enigma_encrypt' is not defined
----------------------------------------------------------------------
Ran 9 tests in 0.001s
FAILED (errors=4)
31.10.2023 18:14
31.10.2023 18:14