my version of @dis.sociat.ing's dollcode algorithm in python

Refactor function names, added comments

- encode_256 -> convert_to_int
- encode_dcode -> convert_to_dollcode
- print_dcode -> print_dollcode
- comments explaining each function

+9 -4
+9 -4
main.py
··· 11 11 BASE_NUM = 3 12 12 13 13 14 - def encode_256(input: str): 14 + # encodes input string into integer by using ord() 15 + def convert_to_int(input: str): 15 16 result = 0 16 17 17 18 for char in input: ··· 20 21 return result 21 22 22 23 23 - def encode_dcode(num: int): 24 + # converts encoded base256 int -> bijective base-3 numeration 25 + # then inserts corresponding number (3, 1, 2) into output list 26 + def convert_to_dollcode(num: int): 24 27 output: list[str] = [] 25 28 window: int = num 26 29 ··· 37 40 return output 38 41 39 42 40 - def print_dcode(output: list[str], copy: bool): 43 + # loops dollcode list, appends each output list entry to 44 + # string, then prints or prints + copies if appropriate flag was passed 45 + def print_dollcode(output: list[str], copy: bool): 41 46 string: str = "" 42 47 43 48 for char in output: ··· 51 56 52 57 53 58 def main(input: str, copy: bool): 54 - print_dcode(encode_dcode(encode_256(input)), copy) 59 + print_dollcode(convert_to_dollcode(convert_to_int(input)), copy) 55 60 56 61 57 62 if __name__ == "__main__":