Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 524 Bytes

challenge-04.md

File metadata and controls

25 lines (18 loc) · 524 Bytes

Reto 4: Una caja dentro de otra caja y otra

🔗 Enunciado

Solución

function fitsInOneBox(boxes) {
  return boxes
    .sort(
      (a, b) => Math.min(...Object.values(a)) - Math.min(...Object.values(b))
    )
    .every((box, idx) => {
      if (idx === boxes.length - 1) return true

      const nextBox = boxes[idx + 1]

      if (box.l >= nextBox.l || box.w >= nextBox.w || box.h >= nextBox.h) return false

      return true
    })
}

🚀 110 puntos