using System.Collections.Generic;
public int flashid { get; set; }
public int position { get; set; }
public string value { get; set; }
static void Recursive(record record, List<string> bag, Stack<record> stack, List<record> list)
if (record.position == 10)
var temp = new StringBuilder();
foreach (var item in stack)
temp.Insert(0, item.value);
bag.Add(temp.ToString());
foreach (var item in list.Where(x => x.position == record.position + 1))
Recursive(item, bag, stack, list);
static List<string> Solve(List<record> list)
for (var i = 1; i <= 10; i++)
if (!list.Any(x => x.position == i))
list.Add(new record { position = i, value = "." });
var bag = new List<string>();
var stack = new Stack<record>();
foreach (var record in list.Where(x => x.position == 1))
Recursive(record, bag, stack, list);
public static void Main()
var list = new List<record>
new record{ flashid = 450, position = 5, value = "a"},
new record{ flashid = 450, position = 6, value = "b"},
new record{ flashid = 450, position = 7, value = "c"},
new record{ flashid = 450, position = 7, value = "d"},
new record{ flashid = 450, position = 7, value = "e"},
new record{ flashid = 450, position = 8, value = "f"},
new record{ flashid = 450, position = 9, value = "g"}
var answer = Solve(list);
Console.WriteLine("[" + string.Join(", ", answer) + "]");