: Forgetting to use .toLowerCase() can cause your program to drop uppercase letters or output blank spaces, as ALPHABET.indexOf("A") returns -1 .
The encoding rule uses modular arithmetic (modulo 26) to handle the end of the alphabet. For example, if the letter is 'Z', shifting by 5 wraps around to 'E'.
In other words, you’ll create two functions:
Write a decode() function that accurately restores the ciphertext back to plaintext.
You have several valid strategies. Let’s explore the most common ones. 83 8 create your own encoding codehs answers exclusive
The code above is reversible and deterministic.
CodeHS exercise 8.3.8, part of the "Encoding Text with Binary" lesson, tasks students with building a custom character encoding scheme from scratch. Unlike standard systems like ASCII, which assigns a fixed 7‑bit code to every character, this open‑ended challenge encourages creativity—your encoding can use variable‑length codes, assign shorter patterns to frequent letters (inspired by Huffman coding), or follow any logical mapping you design.
This approach demonstrates a true "custom" encoding, as the receiver would need to know to subtract 5 to decode the message properly.
If you want to tailor your custom encoder further, let me know: : Forgetting to use
The official problem guide (accessible to teachers) outlines these expectations:
A standard way to solve this is to assign each character a unique 5-bit binary code starting from Binary Code Encoding Example: "HELLO WORLD"
This public link is valid for 7 days and shares a thread, including any personal information you added. This link or copies made by others cannot be deleted. If you share with third parties, their policies apply. Can’t copy the link right now. Try again later.
Note: Some implementations may allow a variable-length encoding, but a fixed-length 5-bit mapping for all characters (A-Z + space) is the most robust approach to ensure all characters are covered and the autograder accepts it. 3. Step-by-Step Implementation Guide When you open the CodeHS IDE for 8.3.8: In other words, you’ll create two functions: Write
Note that a space is included as the first character.
: You must use the fewest number of bits possible to represent your set.
# To decode, we subtract the shift. # We add 26 before modulo to ensure the number stays positive. new_index = (index - 5 + 26) % 26
I'll cite the Chegg question as the source for the requirements. I'll also cite the CodeHS course pages that show the exercise exists.