1
0
Fork 0
forked from itec/banana
banana/banana.py
2020-08-04 09:59:27 +02:00

43 lines
No EOL
1.2 KiB
Python

import argparse
def get_args():
parser = argparse.ArgumentParser(description="Create banana words")
parser.add_argument("num", help="number to be converted", type=int)
parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+', default=[list("bcdfglmnprstvz"), list("aeiou")]) # , list("123456")
parser.add_argument("--exactlength", help="Set exact length", type=int, default=0)
parser.add_argument("--minlength", help="Set minimum length", type=int, default=0)
parser.add_argument("--dictstart", help="Set starting dictionary", type=int, default=0)
parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int, default=0)
args = parser.parse_args()
return args
def main():
args = get_args()
dictionary = args.dictionary
numdict = len(dictionary)
minlength = args.minlength
v = args.num
st = ""
i = (numdict - 1 + args.dictstart + args.shiftend) % numdict
while not (v == 0 and i == (numdict - 1 + args.dictstart) % numdict):
r = v % len(dictionary[i])
v = int(v / len(dictionary[i]))
st = dictionary[i][r] + st
i = (i - 1) % numdict
print(st)
if __name__ == "__main__":
main()