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

92
Vistas
I know how to do it with a different set of numbers but not with these

I was asked to make a pattern like the below:

11111
12221
12321
12221
11111

While messing around and figuring it out I could only do:

55555
54445
54345
54445
55555

Using the code below, I want to know if I can use the same framework and change variables and such to get the desired output. (Note: The code must use nested for loops)

function m(c){
    var maxi=0
    for(var i =0; i<c.length; i++){
        if(maxi<c[i]){
            maxi=c[i]
        }
    }
    return(maxi)
}
var n = 5
for(var i = 0; i<n; i++){
    var a = ''
    for(var j = 0; j<n; j++){
        a+= String(m([i+1,j+1, n-i,n-j]))
    }
    console.log(a)
}
about 4 years ago · Juan Pablo Isaza
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