83 8 Create Your Own Encoding Codehs Answers Exclusive
If you’ve been working through CodeHS or teaching an intro CS course, encryption and encoding exercises are a great way to introduce students to binary, ASCII, and simple ciphers. This post walks through a clear, classroom-ready lesson titled “Create Your Own Encoding,” explains the learning goals, gives a step-by-step activity (with sample student answers), provides extensions and assessment ideas, and includes an exclusive answer key you can use to check student work.
def main(): print("Welcome to the Shift-5 Cipher Machine!") print("This program encodes and decodes messages using a secret shift key of 5.") print("")
# Testing the Encoder
original_text = input("Enter a message to encode: ")
secret_text = encode(original_text)
print("Encoded Message: " + secret_text)
print("")
# Testing the Decoder
print("Now decoding the message back to English...")
translated_back = decode(secret_text)
print("Decoded Message: " + translated_back)
if name == "main": main()
A typical 8.3.8 assignment expects:
The decoding process is the exact inverse of the encoding process. The program takes the encoded text and shifts every letter backward by 5 positions.
Mathematically, if Encoding is index + key, Decoding is index - key.
def encode(text):
text = text.upper()
encoded = []
for ch in text:
if ch in encode_map:
encoded.append(encode_map[ch])
else:
encoded.append('?') # handle unknown chars
return ' '.join(encoded)
The title of the exercise suggests you should "create your own." While using standard ASCII (ord) is the most common way to complete the assignment, you could technically create a "custom" encoding by shifting the numbers.
For example, a Shift Cipher (Caesar Cipher) approach:
message = "HELLO"
encoded_message = []
shift_amount = 5
for char in message:
# Get ASCII value, add 5, then store
custom_code = ord(char) + shift_amount
encoded_message.append(custom_code)
print(encoded_message)
# Output for "HELLO" with shift 5 would be higher numbers than standard ASCII
This approach demonstrates a true "custom" encoding, as the receiver would need to know to subtract 5 to decode the message properly.
In the world of CodeHS 8.3.8 , encoding is about more than just numbers—it is about creating a secret language that only you and your chosen "partner" can understand. The Story of the Silent Signal
In a high-tech city called Bit-Opolis, two engineers, Ada and Bo, needed to send messages past a nosy surveillance drone that only recognized standard 83 8 create your own encoding codehs answers exclusive
text. If they sent "HELLO," the drone would intercept it immediately. To stay hidden, Bo proposed a custom encoding scheme
. Instead of using the standard 8-bit ASCII (which has 256 possible characters), Bo realized they only needed to send capital letters (A-Z) and a space. To be efficient, Bo calculated that they only needed for their code, since , which is plenty for 26 letters and a space. Their Secret Code Table: When Bo sent 00111 00100 01011 01011 01110
(H-E-L-L-O), the drone saw only a string of meaningless zeros and ones. But Ada, using their shared key, translated the "Silent Signal" instantly. By creating their own rules, they didn't just send a message; they built a private bridge that no one else could cross. How to Build Your Answer
To pass the CodeHS autograder for this exercise, your solution must meet these specific requirements: Bit Count: fewest bits possible
to represent A-Z and a space. Since there are 27 characters total,
is the correct answer (4 bits only allows 16 characters, while 5 allows 32). Character Set: Ensure your table includes every capital letter from space character Binary Mapping: Assign a unique 5-digit binary string (like ) to each character. A common pattern is to start A at and work your way up. Example for "HELLO WORLD": If you use the standard 5-bit mapping where A=0, B=1, etc.: (7th index if A=0) → (4th index) → (11th index) → (14th index) → Python dictionary
In CodeHS 8.3.8: Create Your Own Encoding, your goal is to design a binary representation for a custom character set. While "8.3.8" can refer to different exercises depending on your specific course (like Word Ladder in Python), the "Create Your Own Encoding" activity specifically focuses on building a binary-to-text mapping. Core Requirements for the Encoding
To pass the autograder for this specific task, your encoding scheme must meet several criteria:
Completeness: Your scheme must include all capital letters (A-Z) and a Space character.
Efficiency: You must use the fewest number of bits possible to represent your set. If you’ve been working through CodeHS or teaching
Structure: Every character must use the same fixed bit length (e.g., all characters are 5 bits long) to allow for consistent decoding. Determining the Bit Length
Since you need to encode 26 letters (A-Z) plus 1 space (27 characters total), you use the formula (Too small) (Fits all 27 characters with room for 5 extra symbols) Result: Your encoding should use 5 bits per character. Example Encoding Table (5-Bit) You can use a simple sequential mapping. For example: A 00000 K 01010 U 10100 B 00001 L 01011 V 10101 C 00010 M 01100 W 10110 D 00011 N 01101 X 10111 E 00100 O 01110 Y 11000 F 00101 P 01111 Z 11001 G 00110 Q 10000 Space 11010 H 00111 R 10001 I 01000 S 10010 J 01001 T 10011 How to Implement on CodeHS
Open the Encoding Tool: Use the interface provided in the assignment to enter your "Key" (the binary code) and its corresponding "Value" (the character).
Enter All Characters: Ensure you manually add every letter from A to Z and the Space.
Check for Errors: If the autograder fails, double-check that you haven't missed the space character or used more than 5 bits. Alternative: 8.3.8 Word Ladder (Python)
If your "8.3.8" assignment is actually the Word Ladder coding exercise, you need to create a get_index and get_letter function. The core logic for replacing a character at a specific index in Python is:
# To change a letter at a specific index new_word = word[:index] + new_letter + word[index+1:] Use code with caution. Copied to clipboard
You can find more specific troubleshooting for this version on the CodeHS Word Ladder forum.
Which CodeHS course are you currently working through (e.g., Intro to Python, Computing Ideas, or AP CSP)?
To complete the CodeHS 8.3.8: Create your own Encoding assignment, you must define a custom binary mapping for at least 27 characters, including the full English alphabet (A-Z) and a space. The Custom Encoding Solution You need 5 bits per character to support 27 unique values ( if name == " main ": main()
). In the CodeHS interface, you will typically enter these into the metadata or side panel keys.
A-Z Mapping: Start with A at 00000 and increment by one for each letter.
Space Mapping: Assign 11010 (the 27th value) to represent a space. Binary Code Binary Code A 00000 N 01101 B 00001 O 01110 C 00010 P 01111 D 00011 Q 10000 E 00100 R 10001 F 00101 S 10010 G 00110 T 10011 H 00111 U 10100 I 01000 V 10101 J 01001 W 10110 K 01010 X 10111 L 01011 Y 11000 M 01100 Z 11001 Space 11010 Steps to Pass the Autograder
Define the Metadata: Ensure you set the number of bits to 5 in the assignment settings.
Populate the Key: Enter every letter from A to Z and the space character into the encoding table provided in the CodeHS editor.
Use Fewest Bits: The autograder specifically checks if you used the minimum amount of bits required (5) for the 27 characters.
Encoding "HELLO WORLD": Using this table, H is 00111, E is 00100, etc. The phrase "HELLO WORLD" would be represented as a continuous string of these 5-bit sequences.
This assignment asks you to invent a cipher—a system for scrambling text—and implement both an encoder and a decoder. The most common and reliable approach for this assignment is the Caesar Cipher (shifting the alphabet), but with a twist to ensure it is "your own."
Here is the complete solution, explanation, and breakdown.