LogoWCF

dallinstevens's Solution

2025 Solution Deno

if (import.meta.main) {
  const file = "large_message_encoded.txt";
  const text = await Deno.readTextFile(file);

  let decodedMessage = "";

  for (let i = 0; i < text.length; i++) {
    // Check if backslash indicating an encoded character
    if (text.charCodeAt(i) == 92) {
      const encodedNum = parseInt(text[i + 1] + text[i + 2]);
      // check if escaped backslash
      if (text.charCodeAt(i + 1) == 92) {
        decodedMessage += "\\";
        i++;
      }
      // check if character is lowercase letter
      else if (encodedNum >= 0 && encodedNum <= 25) {
        decodedMessage += String.fromCharCode(encodedNum + 97);
        i += 2;
      }
      // check if character is uppercase
      else if (encodedNum >= 26 && encodedNum <= 51) {
        decodedMessage += String.fromCharCode(encodedNum + 39);
        i += 2;
      }
    } else {
      decodedMessage += text[i];
    }
  }
  console.log(decodedMessage);
}

Day 2: Counting Santa's Letters

To help keep things efficient at the North Pole, Santa uses a text intercom system to pass messages. But right now that system is bugging out! It isn’t correctly decoding messages!

Problem: Create a decoder for the following encoding scheme:

There are two files: small_message_encoded.txt, which you can test on, and large_message_encoded.txt, which you should also decode and then share if you can hear “it” to prove you completed the challenge.

Example:
Input:

\33\04\11\11\14, \48\14\17\11\03!

Output:

Hello, World!