Skip to content

Instantly share code, notes, and snippets.

@boxpositron
Last active April 11, 2024 23:35
Show Gist options
  • Save boxpositron/f05b6187254264b371386725b380e004 to your computer and use it in GitHub Desktop.
Save boxpositron/f05b6187254264b371386725b380e004 to your computer and use it in GitHub Desktop.
from typing import Optional
def generate_bit_binaries(size: Optional[int] = 8) -> None:
namespace = 2 ** size
for i in range(namespace): # 256 because 2^8 = 256
# Format the number as a binary with leading zeros
binary_format = f"{i:08b}"
print(binary_format)
if __name__ == "__main__":
generate_bit_binaries()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment