From 7d402b4136a36ac88fe62e6a0720b12c932dccf1 Mon Sep 17 00:00:00 2001 From: itec78 Date: Tue, 4 Aug 2020 09:59:27 +0200 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ .~lock.Banana.xls# | 1 + banana.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 .gitignore create mode 100644 .~lock.Banana.xls# create mode 100644 banana.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4b1242b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Banana.xls +BananaOrd.txt diff --git a/.~lock.Banana.xls# b/.~lock.Banana.xls# new file mode 100644 index 0000000..d48b843 --- /dev/null +++ b/.~lock.Banana.xls# @@ -0,0 +1 @@ +,itec,otorottoc,03.08.2020 17:44,file:///home/itec/.config/libreoffice/4; \ No newline at end of file diff --git a/banana.py b/banana.py new file mode 100644 index 0000000..411e34d --- /dev/null +++ b/banana.py @@ -0,0 +1,43 @@ +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() \ No newline at end of file