def decode(binary): """Decodes a sequence of binary number strings into a list of numbers.""" decoded = [] for binary in binary.split(): number = int(binary, 2) decoded.append(number) return decoded def decrypt(codes, key): """Decrypts a sequence of numbers by applying the XOR operation to each number and the next number in the key.""" cleartext = "" key_index = 0 for code in codes: key_code = ord(key[key_index]) # Decrypt: combine one number in the ciphertext and the key using XOR. plaintext = code ^ key_code cleartext += chr(plaintext) # Take the next character in the key, wrapping around to 0 if we reach the key's end. key_index = (key_index + 1) % len(key) return cleartext print(decrypt(decode(ciphertext), "ROMANSHORN"))