83 8 Create Your Own: Encoding Codehs Answers
Example A — Fixed-length binary (5-bit) for lowercase letters and space
Assign a unique 5-bit binary string to each character. A common and simple approach is to start with A at 0 and proceed sequentially: A = 00000 B = 00001 C = 00010 Z = 11001 Space = 11010 (or any remaining value up to 11111 ).
Set the "Bits in Encoding" to 5 to accommodate the mapping above. 83 8 create your own encoding codehs answers
In the CodeHS Introduction to Computer Science curriculum, challenges you to move beyond standard systems like ASCII or Binary. Instead, you must design, implement, and test your own custom text-encoding algorithm using Python.
for char in text: # If the letter is a vowel, swap it for the next vowel if char == 'a': result += 'e' elif char == 'e': result += 'i' elif char == 'i': result += 'o' elif char == 'o': result += 'u' elif char == 'u': result += 'a' else: # Keep all other letters/numbers/spaces the same result += char Example A — Fixed-length binary (5-bit) for lowercase
Changing a letter to the next one in the alphabet (e.g., 'a' becomes 'b').
: Each character must have exactly the same bit length (e.g., all must be 5 bits) for the message to be decodable. In the CodeHS Introduction to Computer Science curriculum,
Creating your own encoding means building your own "secret code" or mapping table. You decide that 'A' should be represented as "001" , 'B' as "010" , and so on. This "secret code" forms the foundation of your encoding system. In JavaScript, you can implement this mapping using a simple JavaScript object (dictionary).
