Last active
December 7, 2025 19:06
-
-
Save MarianoGnu/001a6382a4d90dfd8cc2d8118b1641a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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