Skip to main content
1 of 3
xigoi
  • 7.3k
  • 2
  • 13
  • 23

Jelly, 13 bytes

Encode, 7 bytes

1,0ṁx‘Ḅ

Try it online!

Decode, 6 bytes

ȯIBŒɠ’

Try it online!

Encodes positive integers in the run lengths of the binary representation. Since we may have zeros, we increment all numbers. For example, the list [0,1,4] is encoded as 10011111 in binary.

xigoi
  • 7.3k
  • 2
  • 13
  • 23