Added script for functions coverting

This commit is contained in:
2018-05-22 21:38:34 +03:00
parent 494e697738
commit e1f636e1ec

21
nums_to_funcs.py Normal file
View File

@@ -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))))