From: equilet <2237372+equilet@users.noreply.github.com> Date: Tue, 23 Jan 2024 01:23:49 +0000 (-0800) Subject: adding combinatorics python demo X-Git-Tag: v0.1~8 X-Git-Url: https://git.dabkitsch.com/?a=commitdiff_plain;h=bc038e60e82285595ed31fc44e971acc305e2366;p=morphograph.git adding combinatorics python demo --- diff --git a/help/combinatorics.py b/help/combinatorics.py new file mode 100644 index 0000000..483a376 --- /dev/null +++ b/help/combinatorics.py @@ -0,0 +1,32 @@ +# python program to demonstrate +# unique combination of two lists +# using zip() and permutation of itertools + +# import itertools package +import itertools +from itertools import permutations + +# initialize lists +list_1 = ["energy", "zcr", "hfc","specirr", "speckurt", "speccrest", "specflat", "specskew"] +list_2 = ["xscale", "yscale", "size", "ylocation", "brightness", "rotation", "linewidth"] + +#list_1 = ["a", "b", "c"] +#list_2 = [1, 2, 3] + +# create empty list to store the +# combinations +unique_combinations = [] + +# Getting all permutations of list_1 +# with length of list_2 +permut = itertools.permutations(list_1, len(list_2)) + +# zip() is called to pair each permutation +# and shorter list element into combination +for comb in permut: + zipped = zip(comb, list_2) + unique_combinations.append(list(zipped)) + +# printing unique_combination list +#print(unique_combinations) +print(sum(1 for e in unique_combinations)) diff --git a/help/svgtest.svg b/help/svgtest.svg deleted file mode 100644 index b6d8beb..0000000 --- a/help/svgtest.svg +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file