.NET 3.x Перебор всевозможных комбинаций символов строки, исправить код - C#
Формулировка задачи:
Увидел код с подбором цифр... решил буквы добавить, но вышла ошибка...
Пожалуйста, скажите как правильно это сделать?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace muuxxacc
{
class Program
{
static void Main(string[] args)
{
string t = "t";
string m = "m";
string a = "a";
var x = P(new[] { 0, 3, t, m, a, 9 }, 6);
x.Select(i =>
{
i.Select(j =>
{
Console.Write(j + " ");
return 0;
}).ToList();
Console.WriteLine();
return 0;
}).ToList();
Console.ReadKey();
}
static List<List<int>> P(IEnumerable<int> set, int n)
{
var result = new List<List<int>> { null };
for (var i = 0; i < n; i++)
{
var tresult = new List<List<int>>();
foreach (var tuple in result)
{
foreach (var item in set)
{
var ttuple = new List<int>(tuple ?? new List<int>());
ttuple.Add(item);
tresult.Add(ttuple);
}
}
result = tresult;
}
return result;
}
}
}Решение задачи: «.NET 3.x Перебор всевозможных комбинаций символов строки, исправить код»
textual
Листинг программы
var result = new List<List<char>> { null };