Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 597 Bytes

challenge-22.md

File metadata and controls

24 lines (19 loc) · 597 Bytes

Reto 22: La iluminación en sintonía

🔗 Enunciado

Solución

function checkStepNumbers(systemNames, stepNumbers) {
  return Object.values(
    systemNames.reduce((systems, name, idx) => {
      if (Object.hasOwn(systems, name)) systems[name].push(stepNumbers[idx])
      else if (!Object.hasOwn(systems, name)) systems[name] = [stepNumbers[idx]]

      return systems
    }, {})
  ).every(
    (system) =>
      system.join('') === system.sort().join('') &&
      system.length === new Set(system).size
  )
}

🚀 140 puntos