Added script for functions coverting
This commit is contained in:
21
nums_to_funcs.py
Normal file
21
nums_to_funcs.py
Normal 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))))
|
||||||
Reference in New Issue
Block a user