Skip to content

Instantly share code, notes, and snippets.

@boxpositron
Last active April 11, 2024 23:35
Show Gist options
  • Select an option

  • Save boxpositron/f05b6187254264b371386725b380e004 to your computer and use it in GitHub Desktop.

Select an option

Save boxpositron/f05b6187254264b371386725b380e004 to your computer and use it in GitHub Desktop.

Revisions

  1. boxpositron revised this gist Apr 11, 2024. 1 changed file with 13 additions and 5 deletions.
    18 changes: 13 additions & 5 deletions every_combination.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,15 @@
    def generate_8bit_binaries():
    for i in range(256): # 256 because 2^8 = 256
    binary_format = f"{i:08b}" # Format the number as a binary with leading zeros
    print(binary_format)
    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_8bit_binaries()
    generate_bit_binaries()
  2. boxpositron created this gist Apr 11, 2024.
    7 changes: 7 additions & 0 deletions every_combination.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    def generate_8bit_binaries():
    for i in range(256): # 256 because 2^8 = 256
    binary_format = f"{i:08b}" # Format the number as a binary with leading zeros
    print(binary_format)

    if __name__ == "__main__":
    generate_8bit_binaries()