Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
Polybius Square Javascript Map Function

I'm working on a problem solving a polybius square functionality. I am having trouble figuring out how to create a polybius square function. with the following instructions:

The polybius() function in the src/polybius.js file has two parameters:

input refers to the inputted text to be encoded or decoded. encode refers to whether you should encode or decode the message. By default it is set to true . When building the function, keep the following constraints and rules in mind:

You are welcome to assume that no additional symbols will be included as part of the input. Only spaces and letters will be included. When encoding, your output should still be a string. When decoding, the number of characters in the string excluding spaces should be even. Otherwise, return false . Spaces should be maintained throughout. Capital letters can be ignored. The letters "I" and "J" share a space. When encoding, both letters can be converted to 42 , but when decoding, both letters should somehow be shown.

& basically, I got to here with my code:

    const cipher = (input, encode = true) => {
  const direction = encode ? encoder : decoder;

  return input
    .match(/[0-9]{2}|[a-z]|\s/g)
    .map(character => direction[character] || character)
    .join('');
};

but i'm lost on how I would do this for the i/j exception when I am decoding a string. Any thoughts?

    const encoder = { 'a': '11', 'b': '12', 'c': '13', 'd': '14', 'e': '15', 'f': '21', 'g': '22', 'h': '23', 'i/j': '24', 'k': '25', 'l': '31', 'm': '32', 'n': '33', 'o': '34', 'p': '35', 'q': '41', 'r': '42', 's': '43', 't': '44', 'u': '45', 'v': '51', 'w': '52', 'x': '53', 'y': '54', 'z': '55' };
const decoder = { '11': 'a', '12': 'b', '13': 'c', '14': 'd', '15': 'e', '21': 'f', '22': 'g', '23': 'h', '24': 'i/j', '25': 'k', '31': 'l', '32': 'm', '33': 'n', '34': 'o', '35': 'p', '41': 'q', '42': 'r', '43': 's', '44': 't', '45': 'u', '51': 'v', '52': 'w', '53': 'x', '54': 'y', '55': 'z' };

TL:DR -> Need to figure out how to use the .map function for i/j exception for decoding a polybius string

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try with these:

var txt=txt.toLowerCase().replace('j','i') 
var r='' 
for(var a=0;a0){ 
    if(t.substr(0,1)==' '){ 
        r+=' ' 
        c=1 
    } 
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda