Created
May 22, 2020 21:05
-
-
Save WisdomWolf/082d5e0f2b47345a6ac675c6a8ebae52 to your computer and use it in GitHub Desktop.
Slay The Spire Seed Conversion Functions
This file contains 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
def convert_seed_to_string(seed: int) -> str: | |
"""Converts numeric seed from run file to alphanumeric seed""" | |
char_string = string.digits + string.ascii_uppercase | |
# Convert to unsigned | |
leftover = seed = seed + 2**64 if seed < 0 else seed | |
char_count = len(char_string) | |
result = [] | |
while leftover != 0: | |
remainder = leftover % char_count | |
leftover = leftover // char_count | |
index = int(remainder) | |
c = char_string[index] | |
result.insert(0, c) | |
return ''.join(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment