83 8 Create Your Own Encoding Codehs Answers (2026)
: Ensure you clearly state how many bits your encoding uses.
: Choose 5 bits as your standard length to ensure you have enough unique combinations (32 total) for all 27 characters. Assign Values
Objective: Implement a simple encoder and decoder, then analyze compression.
The "8.3.8 Create Your Own Encoding" challenge on CodeHS is a pivotal moment in the Intro to Computer Science curriculum. It shifts from simply following instructions to designing a custom algorithm. 83 8 create your own encoding codehs answers
Here are some sample answers for the 83.8 create your own encoding CodeHS exercise:
for (var len = 2; len >= 1; len--) var slice = encodedMessage.substr(i, len); if (decodingMap[slice] !== undefined) decoded += decodingMap[slice]; i += len; found = true; break;
my_decoder = {} for key, value in my_encoding.items(): my_decoder[value] = key : Ensure you clearly state how many bits your encoding uses
For messages under 10,000 characters, even an O(n²) decode is fine. The CodeHS tests are short.
If the user enters a symbol (like ! ) that isn't in your map, your code should either skip it or handle it gracefully to avoid a KeyError .
# Part 1: Define the Encoding Scheme (The "Code Book") # We map characters to unique binary strings. # Note: A real scheme might use ASCII values, but here we create our own. The "8
In this exercise, we'll dive into the world of encoding and create our own simple encoding scheme. This project is inspired by the popular CodeHS activity "83 8 Create Your Own Encoding."
my_encoding = 'A': '00001', 'B': '00010', 'C': '00011', 'D': '00100', 'E': '00101', 'F': '00110', 'G': '00111', 'H': '01000', 'I': '01001', 'J': '01010', 'K': '01011', 'L': '01100', 'M': '01101', 'N': '01110', 'O': '01111', 'P': '10000', 'Q': '10001', 'R': '10010', 'S': '10011', 'T': '10100', 'U': '10101', 'V': '10110', 'W': '10111', 'X': '11000', 'Y': '11001', 'Z': '11010', ' ': '11111' # Encoding for Space
What or unexpected behavior are you currently running into?