469,125 Members | 1,709 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

Permutation for Web application

I have Created a webapplication which displays the combination of inputs supplied.
Expand|Select|Wrap|Line Numbers
  1.                         Permutation<string> permutations = new Permutation<string>(inputSet);
  2.                         foreach (IList<string> p in permutations)
  3.                         {
  4.                             dr = dt.NewRow();
  5.                             dr1 = dt.NewRow();
  6.  
  7.                             if (!string.IsNullOrEmpty(txtFirst.Text) || !string.IsNullOrEmpty(txtSecond.Text))
  8.                             {
  9.                                 dr["Shuffle"] = String.Format("{0} {1}   ", p[0], p[1]);
  10.  
  11.                                 dr["Shuffle"] = dr["Shuffle"] + ", " + txtFirst.Text + " " + txtSecond.Text;
  12.  
  13.                                 dt.Rows.Add(dr);
  14.                             }
  15.                             else
  16.                             {
  17.                                 dr["Shuffle"] = String.Format("{0} {1}  ", p[0], p[1]);
  18.  
  19.                                 dt.Rows.Add(dr);
  20.                             }
  21.                         }
  22.  
  23.  
  24.  
  25.  
  26.                         /////// THREE COMBINATION
  27.  
  28.                         Permutation<string> permutations2 = new Permutation<string>(inputSet);
  29.                         foreach (IList<string> p in permutations2)
  30.                         {
  31.                             dr = dt.NewRow();
  32.                             dr2 = dt.NewRow();
  33.  
  34.                             if (!string.IsNullOrEmpty(txtFirst.Text) || !string.IsNullOrEmpty(txtSecond.Text))
  35.                             {
  36.                                 dr2["Shuffle"] = String.Format("{0} {1} {2}  ", p[0], p[1], p[2]);
  37.  
  38.                                 dr2["Shuffle"] = dr2["Shuffle"] + ", " + txtFirst.Text + " " + txtSecond.Text;
  39.  
  40.                                 dt.Rows.Add(dr2);
  41.                             }
  42.                             else
  43.                             {
  44.                                 dr2["Shuffle"] = String.Format("{0} {1} {2} ", p[0], p[1], p[2]);
  45.  
  46.                                 dt.Rows.Add(dr2);
For two and three combination of names it is displaying but if i try to add for four combination. the combinations are repeating. please help me on this.
May 23 '11 #1
0 917

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Talin | last post: by
3 posts views Thread by Jack Middleton | last post: by
1 post views Thread by user | last post: by
6 posts views Thread by Rajesh | last post: by
27 posts views Thread by onkar | last post: by
3 posts views Thread by weidongtom | last post: by
reply views Thread by 249740 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.