To satisfy the requirement of creating your own encoding (rather than just copying a standard Caesar Cipher), this solution uses a specific rule:
Example: A→1, B→2, C→3, space→0
encode_map =
'A': '1', 'B': '2', 'C': '3', 'D': '4', 'E': '5',
'F': '6', 'G': '7', 'H': '8', 'I': '9', 'J': '10',
'K': '11', 'L': '12', 'M': '13', 'N': '14', 'O': '15',
'P': '16', 'Q': '17', 'R': '18', 'S': '19', 'T': '20',
'U': '21', 'V': '22', 'W': '23', 'X': '24', 'Y': '25',
'Z': '26', ' ': '0'
Below are several example student encodings and how to decode them. Use these as model answers. 83 8 create your own encoding codehs answers exclusive
Example A — Decimal two-digit scheme (alphabet A–Z, space = 27)
Example B — Binary 5-bit scheme (A=00001 … Z=11010, space=11011) To satisfy the requirement of creating your own
Example C — Symbol pair scheme (2-symbol tokens)
Example D — Simple substitution shift (Caesar-like) using numbers Below are several example student encodings and how
alphabet = "abcdefghijklmnopqrstuvwxyz "
mapping = alphabet[i]: i+1 for i in range(len(alphabet))
reverse_mapping = v: k for k, v in mapping.items()
This allows any custom ordering. A student could map ‘z’ to 1, ‘y’ to 2, etc. This is more original.
original = "HELLO WORLD"
encoded = encode(original)
decoded = decode(encoded)
print("Original:", original)
print("Encoded :", encoded)
print("Decoded :", decoded)