Skip to content

Instantly share code, notes, and snippets.

@tildejustin
Last active February 21, 2023 04:00
Show Gist options
  • Save tildejustin/c212e25d2f713e67f7d3c115221d9128 to your computer and use it in GitHub Desktop.
Save tildejustin/c212e25d2f713e67f7d3c115221d9128 to your computer and use it in GitHub Desktop.
generates all sister seeds of an inputted seed and stores them in "<seed>_sisters.txt"
# Copyright (c) 2023 tildejustin
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# "imagine using a signed long, couldn't be me"
structure_seed_len = 48
top_seed_len = 16
seed_len = 64
def main() -> None:
seed = int(input("Input a seed: "))
structure_seed = seed & 2**structure_seed_len - 1
print("structure seed: " + "0" * 15 + bin(structure_seed)[2:])
# correct in binary, but python doesn't recognize two's complement notation
# and just thinks they're all positive numbers :P
sister_seeds_temp = [
(num << structure_seed_len) + structure_seed for num in range(2**16)
]
sister_seeds = map(str, map(twos_complement, sister_seeds_temp))
with open(f"{seed}_sisters.txt", "w") as file:
file.write("\n".join(sister_seeds))
def twos_complement(bin_num: int) -> int:
if bin_num >> seed_len - 1 == 0:
return bin_num
return bin_num - 2**seed_len
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment