Permutations between two lists of unequal length
The simplest way is to use itertools.product: a = [“foo”, “melon”] b = [True, False] c = list(itertools.product(a, b)) >> [(“foo”, True), (“foo”, False), (“melon”, True), (“melon”, False)]
The simplest way is to use itertools.product: a = [“foo”, “melon”] b = [True, False] c = list(itertools.product(a, b)) >> [(“foo”, True), (“foo”, False), (“melon”, True), (“melon”, False)]
How to generate all permutations of a list?
Create an array of all your characters and then do a nested foreach loop to generate each possible combination. static void Main() { IList<char> characters = new List<char> {‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘1’, ‘2’, ‘3’}; foreach (char c1 in characters) { foreach (char c2 in characters) { Console.WriteLine(new string(new[] {c1, c2})); } … Read more