Skip to main content
Share Your Experience: Take the 2024 Developer Survey
1 of 2
PurkkaKoodari
  • 17.9k
  • 2
  • 34
  • 90

Jelly, 25 bytes

L€MḢ
ṖṖ;⁽÷ẓỌµ€Ç¦µj⁴L>⁵ð¿j

Try it online!

This unfortunately does not contain the error-if-invalid feature.

PurkkaKoodari
  • 17.9k
  • 2
  • 34
  • 90