diff --git a/nums_to_funcs.py b/nums_to_funcs.py new file mode 100644 index 0000000..89cb4f2 --- /dev/null +++ b/nums_to_funcs.py @@ -0,0 +1,21 @@ +import sys + +def num_to_func(n): + res = [] + pattern = "0???1???2" + for ch in pattern[::-1]: + if ch != "?": + res.append(ch) + continue + res.append(n % 3) + n = n // 3 + res = "".join((str(x) for x in res[::-1])) + return res[:3] + " " + res[3:6] + " " + res[6:] + +if __name__ == "__main__": + with open(sys.argv[1]) as f_in: + for line in f_in: + line = line.strip() + if not line: + continue + print("{} -> {}".format(line, num_to_func(int(line))))