Using .indexOf() or bracket notation to find character positions.
Ensure that if you shift 'Z', it goes back to 'A' rather than turning into a symbol. 3. Writing the decode Function
Create a variable (e.g., encodedText = "" ) to store the encrypted characters as you build them.
The goal is to create a function that substitutes characters for binary values, similar to how Morse code uses dots and dashes . The Solution Strategy
Decide how to map characters. For simplicity, we’ll use:
The exercise on CodeHS isn't about finding a secret answer—it's about mastering the concept of transforming data. The solution above gives you a working, autograder-friendly implementation while teaching you how ord() and chr() form the backbone of text encoding.
Use the charCodeAt() and String.fromCharCode() methods in JavaScript (or similar functions in Python) to shift the numerical value of the character.
Write code that takes your custom binary string and translates it back into the original plain text. 8.3.8 Create Your Own Encoding Solution (Python)
Explain how to use to make the code shorter.
The core of the CodeHS 8.3.8 "Create Your Own Encoding" exercise is to build a simple or Substitution Map .
Example:
: This is essentially a subset of ASCII (a=97 in ASCII). It saves space if you only need lowercase letters and spaces – a form of domain-specific compression .
A) ListB) TupleC) DictionaryD) Set Correct Answer: C) Dictionary ✅
: If you and a partner use the same encoding scheme , you can transmit and decode each other's messages correctly.
Unlike the classic Caesar Cipher (which simply shifts letters by a fixed numeric value), a custom encoding algorithm can combine multiple rules: Replacing specific vowels with symbols or numbers. Reversing string components. Inserting "noise" characters at specific intervals. Manipulating character codes (ASCII/Unicode values).
Character: Space --> Binary Code: 11010 Character: A --> Binary Code: 00000 Character: B --> Binary Code: 00001 Character: C --> Binary Code: 00010 Character: D --> Binary Code: 00011 Character: E --> Binary Code: 00100 ... Character: H --> Binary Code: 00111 ... Character: L --> Binary Code: 01100 ... Character: O --> Binary Code: 01111 ... Character: W --> Binary Code: 10110 Character: R --> Binary Code: 10010 Use code with caution. 4. Run the Sandbox Diagnostic Validation Test
Using .indexOf() or bracket notation to find character positions.
Ensure that if you shift 'Z', it goes back to 'A' rather than turning into a symbol. 3. Writing the decode Function
Create a variable (e.g., encodedText = "" ) to store the encrypted characters as you build them.
The goal is to create a function that substitutes characters for binary values, similar to how Morse code uses dots and dashes . The Solution Strategy
Decide how to map characters. For simplicity, we’ll use: 8.3 8 create your own encoding codehs answers
The exercise on CodeHS isn't about finding a secret answer—it's about mastering the concept of transforming data. The solution above gives you a working, autograder-friendly implementation while teaching you how ord() and chr() form the backbone of text encoding.
Use the charCodeAt() and String.fromCharCode() methods in JavaScript (or similar functions in Python) to shift the numerical value of the character.
Write code that takes your custom binary string and translates it back into the original plain text. 8.3.8 Create Your Own Encoding Solution (Python)
Explain how to use to make the code shorter. Writing the decode Function Create a variable (e
The core of the CodeHS 8.3.8 "Create Your Own Encoding" exercise is to build a simple or Substitution Map .
Example:
: This is essentially a subset of ASCII (a=97 in ASCII). It saves space if you only need lowercase letters and spaces – a form of domain-specific compression .
A) ListB) TupleC) DictionaryD) Set Correct Answer: C) Dictionary ✅ For simplicity, we’ll use: The exercise on CodeHS
: If you and a partner use the same encoding scheme , you can transmit and decode each other's messages correctly.
Unlike the classic Caesar Cipher (which simply shifts letters by a fixed numeric value), a custom encoding algorithm can combine multiple rules: Replacing specific vowels with symbols or numbers. Reversing string components. Inserting "noise" characters at specific intervals. Manipulating character codes (ASCII/Unicode values).
Character: Space --> Binary Code: 11010 Character: A --> Binary Code: 00000 Character: B --> Binary Code: 00001 Character: C --> Binary Code: 00010 Character: D --> Binary Code: 00011 Character: E --> Binary Code: 00100 ... Character: H --> Binary Code: 00111 ... Character: L --> Binary Code: 01100 ... Character: O --> Binary Code: 01111 ... Character: W --> Binary Code: 10110 Character: R --> Binary Code: 10010 Use code with caution. 4. Run the Sandbox Diagnostic Validation Test