Skip to content

Instantly share code, notes, and snippets.

@MarianoGnu
Last active December 7, 2025 19:06
Show Gist options
  • Select an option

  • Save MarianoGnu/001a6382a4d90dfd8cc2d8118b1641a0 to your computer and use it in GitHub Desktop.

Select an option

Save MarianoGnu/001a6382a4d90dfd8cc2d8118b1641a0 to your computer and use it in GitHub Desktop.
func pack(v: Array[bool) -> int:
var r: int = 0
for i in v.size():
r |= (1 << i) * int(v[i])
func unpack(v: int, size: int) -> Array[bool]
var r: Array[bool] = []
r.resize(size)
for i in size:
r[i] = bool(v & (1 << i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment