8.3 8 Create Your Own Encoding Codehs Answers -
The core of the CodeHS 8.3.8 "Create Your Own Encoding" exercise is to build a simple Cipher or Substitution Map.
For a full alphabet, typing the dictionary manually is tedious. You can use two strings of the alphabet and the function if you want to be extra fancy!
Insight: This introduces compression theory – the most interesting computer science concept in the exercise, though often beyond the official rubric. 8.3 8 create your own encoding codehs answers
Solution: Shift Encoder
This code defines a function encode that shifts characters and includes a main function to test it.
Step 4: Common Mistakes & Debugging Tips
When solving 8.3.8, students often run into these issues: The core of the CodeHS 8
result = ""
for i in range(0, len(code), 2):
token = code[i:i+2]
n = int(token)
if n == 27:
result += " "
else if n == 28:
result += "."
else:
result += chr(n - 1 + ord('A'))
return result
Translate: For each character, look up its encoded value in your dictionary and append it to a new result string. 💻 Sample Solution (Python)
In CodeHS Exercise 8.3.8 (also labeled as 8.3.6 in some versions), the objective is to create a custom binary encoding scheme for text. To complete this activity, you must define a unique binary code for each required character and then use it to encode a message. Required Character Set Your encoding must support: Capital letters A-Z Space character Strategy: Choosing the Bit Depth Translate : For each character, look up its
If you wanted to encode the word "CAT", you would replace each letter with its code from your table: C = 00010 A = 00000 T = 10011 Result: 000100000010011 Implementation Tips

















