Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IEnumerable<string> Add(char c, IEnumerable<string> data)
- {
- if (data == null)
- return new[] { new string(c) };
- return data.SelectMany(s => Range(0, s.Length + 1).Select(pos => s.Insert(c, pos)));
- }
- IEnumerable<string> Permute(string s)
- {
- return s.Aggregate((acc, c) =>
- {
- return data == null ?
- new[] { new string(c) } :
- data.SelectMany(s => Range(0, s.Length + 1).Select(pos => s.Insert(c, pos)))
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement