I have a dictionary of lists like so:
var dictOfLists = new Dictionary<string, List<string>>
{
["foo"] = new List<string>{ "a", "b", "c" },
["bar"] = new List<string>{ "d" },
["baz"] = new List<string>{ "e", "a" }
}
I want to convert this to a list of unique dictionaries like so:
var listOfUniqDicts = new List<Dictionary<string, string>>
{
new Dictionary<string, string> {["foo"] = "a", ["bar"] = "d", ["baz"] = "e" },
new Dictionary<string, string> {["foo"] = "a", ["bar"] = "d", ["baz"] = "a" },
new Dictionary<string, string> {["foo"] = "b", ["bar"] = "d", ["baz"] = "e" },
new Dictionary<string, string> {["foo"] = "b", ["bar"] = "d", ["baz"] = "a" },
new Dictionary<string, string> {["foo"] = "c", ["bar"] = "d", ["baz"] = "e" },
new Dictionary<string, string> {["foo"] = "c", ["bar"] = "d", ["baz"] = "a" },
}
(As you can see, in the above list, each of the dictionaries represents a unique combination of values, whose keys map to the respective keys of the initial dictionary.)
Is there a clean algorithm to do this with an arbitrary dictionary of the above type?