Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IEnumerable<string> Add(char c, IEnumerable<string> data)
  2. {
  3.     if (data == null)
  4.         return new[] { new string(c) };
  5.     return data.SelectMany(s => Range(0, s.Length + 1).Select(pos => s.Insert(c, pos)));
  6. }
  7.  
  8. IEnumerable<string> Permute(string s)
  9. {
  10.     return s.Aggregate((acc, c) =>
  11.     {
  12.         return data == null ?
  13.             new[] { new string(c) } :  
  14.             data.SelectMany(s => Range(0, s.Length + 1).Select(pos => s.Insert(c, pos)))
  15.     });
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement