Skip to main content
5 of 5
added 4 characters in body
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

K (oK), 12 7 bytes

-5 bytes thanks to ngn!

A k (oK) port of Arnauld's 05AB1E solution (and tsh's JavaScript solution):

+/0|-':

Try it online!

J, 15 bytes

A J port of Arnauld's 05AB1E solution (and tsh's JavaScript solution):

1#.0>./2-~/\0,]

Try it online!

My naive solution:

J, 27 bytes

1#.2(1 0-:])\0,@|:@,~1$~"0]

Try it online!

Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61